Ulysses

General => Developers Corner => Topic started by: BLEEP_BLOOP on July 31, 2016, 12:02:10 AM

Title: Hook for Ban/Kick
Post by: BLEEP_BLOOP on July 31, 2016, 12:02:10 AM
Is there a hook called when someone gets banned or kicked with ULX. If not, is there some way similar that would accomplish this? Any help is appreciated.
Title: Re: Hook for Ban/Kick
Post by: iViscosity on July 31, 2016, 12:07:33 AM
Looking at the Github for ULX (https://github.com/TeamUlysses/ulib/blob/81044e2a65790d264a45e9bbc54cbe1cb615b64c/lua/ulib/server/player.lua#L158) it looks like it just uses the Player Kick (http://wiki.garrysmod.com/page/Player/Kick) function on the Garry's Mod Wiki (http://wiki.garrysmod.com/).
Title: Re: Hook for Ban/Kick
Post by: BLEEP_BLOOP on July 31, 2016, 12:08:39 AM
Yes, I know that, but is a hook called when it kicks/bans the player? If not, what would be the best way of checking for a kick/ban?
Title: Re: Hook for Ban/Kick
Post by: iViscosity on July 31, 2016, 12:10:19 AM
Yes, I know that, but is a hook called when it kicks/bans the player? If not, what would be the best way of checking for a kick/ban?

It just uses a Gmod function, I don't think it uses a hook. You could check the server logs.
Title: Re: Hook for Ban/Kick
Post by: BLEEP_BLOOP on July 31, 2016, 12:11:51 AM
I'm looking for some way to check if a player has been kicked or banned. So what do you think is the best way to check that through GLua?
Title: Re: Hook for Ban/Kick
Post by: iViscosity on July 31, 2016, 12:12:10 AM
The best way I think would be via server logs if you have access to those.
Title: Re: Hook for Ban/Kick
Post by: BLEEP_BLOOP on July 31, 2016, 12:13:11 AM
I wanted to check for a kick/ban through Lua not to actually look at server logs.
Title: Re: Hook for Ban/Kick
Post by: roastchicken on July 31, 2016, 01:38:35 AM
You can use the ULibCommandCalled (http://ulyssesmod.net/docs/files/lua/ulib/shared/defines-lua.html#ULibCommandCalled) hook to detect when a player is banned. I'm not sure if this will be 100% reliable as it may still be called even if the commands arguments are invalid (i.e. the player will not be banned), but it's your best bet other than parsing the ULX logs.

As for the logs, it is possible to find bans in them via the (http://wiki.garrysmod.com/favicon.ico) file (http://wiki.garrysmod.com/page/file) library. It's just a bit of work figuring out which pattern(s) you need in order to get the bans.
Title: Re: Hook for Ban/Kick
Post by: JamminR on July 31, 2016, 07:21:53 AM
There is also ULibPostTranslatedCommand (http://ulyssesmod.net/docs/files/lua/ulib/shared/defines-lua.html#ULibPostTranslatedCommand) , which might be better as it's only hooks when the ulx commands are properly completed.
The challenge with using ULib library to monitor for kick or ban using commandcalled or posttranslatedcommand is that an admin or above could use standard server kick or ban commands instead of the ULX version. It's possible not many admins might know how to use those two commands, but I used to use them from console when in a hurry.
Ulib would never see those.