ULX

Author Topic: Hook for Ban/Kick  (Read 2850 times)

0 Members and 1 Guest are viewing this topic.

Offline BLEEP_BLOOP

  • Newbie
  • *
  • Posts: 14
  • Karma: 1
Hook for Ban/Kick
« 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.

Offline iViscosity

  • Respected Community Member
  • Hero Member
  • *****
  • Posts: 803
  • Karma: 58
Re: Hook for Ban/Kick
« Reply #1 on: July 31, 2016, 12:07:33 AM »
Looking at the Github for ULX it looks like it just uses the Player Kick function on the Garry's Mod Wiki.
I'm iViscosity. I like gaming and programming. Need some help? Shoot me PM.

Offline BLEEP_BLOOP

  • Newbie
  • *
  • Posts: 14
  • Karma: 1
Re: Hook for Ban/Kick
« Reply #2 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?

Offline iViscosity

  • Respected Community Member
  • Hero Member
  • *****
  • Posts: 803
  • Karma: 58
Re: Hook for Ban/Kick
« Reply #3 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.
I'm iViscosity. I like gaming and programming. Need some help? Shoot me PM.

Offline BLEEP_BLOOP

  • Newbie
  • *
  • Posts: 14
  • Karma: 1
Re: Hook for Ban/Kick
« Reply #4 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?

Offline iViscosity

  • Respected Community Member
  • Hero Member
  • *****
  • Posts: 803
  • Karma: 58
Re: Hook for Ban/Kick
« Reply #5 on: July 31, 2016, 12:12:10 AM »
The best way I think would be via server logs if you have access to those.
I'm iViscosity. I like gaming and programming. Need some help? Shoot me PM.

Offline BLEEP_BLOOP

  • Newbie
  • *
  • Posts: 14
  • Karma: 1
Re: Hook for Ban/Kick
« Reply #6 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.

Offline roastchicken

  • Respected Community Member
  • Sr. Member
  • *****
  • Posts: 476
  • Karma: 84
  • I write code
Re: Hook for Ban/Kick
« Reply #7 on: July 31, 2016, 01:38:35 AM »
You can use the 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 file library. It's just a bit of work figuring out which pattern(s) you need in order to get the bans.
Give a man some code and you help him for a day; teach a man to code and you help him for a lifetime.

Offline JamminR

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 8096
  • Karma: 390
  • Sertafide Ulysses Jenius
    • Team Ulysses [ULib/ULX, other fine releases]
Re: Hook for Ban/Kick
« Reply #8 on: July 31, 2016, 07:21:53 AM »
There is also 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.
"Though a program be but three lines long, someday it will have to be maintained." -- The Tao of Programming