ULX

Author Topic: Ban not adding.  (Read 2802 times)

0 Members and 1 Guest are viewing this topic.

Offline StaTiiKxKALEB

  • Newbie
  • *
  • Posts: 17
  • Karma: 2
Ban not adding.
« on: June 15, 2016, 05:06:35 PM »
I'm trying to get this code to work, but it's not adding the ban when they disconnect. Any ideas?
Code: [Select]
hook.Add("PlayerDisconnect", "BanForCheaterDisconnect", function(ply)
local plysteamid = ply:SteamID()
local plyname = ply:Nick()
local time = 1
local admin = "CONSOLE"
local reason = "(CHEATING) Don'try to cheat."

if ply:IsUserGroup("cheater") then
ULib.addBan(plysteamid, time, reason, plyname, admin)
end
end)
« Last Edit: June 15, 2016, 05:45:15 PM by StaTiiKxKALEB »

Offline Bytewave

  • Respected Community Member
  • Hero Member
  • *****
  • Posts: 718
  • Karma: 116
  • :)
    • My Homepage
Re: Ban not adding.
« Reply #1 on: June 15, 2016, 06:42:36 PM »
Presumably you should be using ULib.ban(ply[, time][, reason][, admin]) instead of ULib.addBan(), but I'm not sure.
bw81@ulysses-forums ~ % whoami
Homepage

Offline JamminR

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 8096
  • Karma: 390
  • Sertafide Ulysses Jenius
    • Team Ulysses [ULib/ULX, other fine releases]
Re: Ban not adding.
« Reply #2 on: June 15, 2016, 06:43:34 PM »
PlayerDisconnectED ?
Notice my emphasis on 'ed'.
You seem to be using an incorrect hook name.

Errors are likely appearing in console when this first gets loaded that would indicate this.
"Though a program be but three lines long, someday it will have to be maintained." -- The Tao of Programming

Offline JamminR

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 8096
  • Karma: 390
  • Sertafide Ulysses Jenius
    • Team Ulysses [ULib/ULX, other fine releases]
Re: Ban not adding.
« Reply #3 on: June 15, 2016, 06:47:15 PM »
ByteWave, now that you point yours out, I'm not sure honestly.
Ban looks for the player and removes them forcefully.
I'm pretty sure addBan could be used since they're already leaving.
"Though a program be but three lines long, someday it will have to be maintained." -- The Tao of Programming

Offline StaTiiKxKALEB

  • Newbie
  • *
  • Posts: 17
  • Karma: 2
Re: Ban not adding.
« Reply #4 on: June 15, 2016, 06:48:39 PM »
PlayerDisconnectED ?
Notice my emphasis on 'ed'.
You seem to be using an incorrect hook name.

Errors are likely appearing in console when this first gets loaded that would indicate this.
Thanks, didn't realize. Simple mistake. Thanks for the help man. Also, thanks for the information @Bytewave. Also, how would I correctly add a user to a group? For right now, I'm using RunConsoleCommand( "ulx", "adduserid", ply:SteamID(), "cheater" )
« Last Edit: June 15, 2016, 06:50:18 PM by StaTiiKxKALEB »

Offline JamminR

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 8096
  • Karma: 390
  • Sertafide Ulysses Jenius
    • Team Ulysses [ULib/ULX, other fine releases]
Re: Ban not adding.
« Reply #5 on: June 15, 2016, 06:54:05 PM »
Well, that should work.
However, since we didn't really dev ULX to be built on (NOT that we mind it), if you're developing only relying on ULib (and not ULX), see
ULib.ucl.addUser
"Though a program be but three lines long, someday it will have to be maintained." -- The Tao of Programming

Offline MrPresident

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 2728
  • Karma: 430
    • |G4P| Gman4President
Re: Ban not adding.
« Reply #6 on: June 15, 2016, 07:23:56 PM »
The first argument of a hook.Add is just a string identifier for that particular hook, if it doesn't exist it won't throw an error, it'll just never get called.

Offline JamminR

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 8096
  • Karma: 390
  • Sertafide Ulysses Jenius
    • Team Ulysses [ULib/ULX, other fine releases]
Re: Ban not adding.
« Reply #7 on: June 15, 2016, 07:54:48 PM »
Thanks MrP.
(Seems silly, would be easier to troubleshoot if they did)
"Unknown hook - nonexistent at line blah"
"Though a program be but three lines long, someday it will have to be maintained." -- The Tao of Programming

Offline Bytewave

  • Respected Community Member
  • Hero Member
  • *****
  • Posts: 718
  • Karma: 116
  • :)
    • My Homepage
Re: Ban not adding.
« Reply #8 on: June 15, 2016, 08:10:14 PM »
Thanks MrP.
(Seems silly, would be easier to troubleshoot if they did)
"Unknown hook - nonexistent at line blah"
Well, when you consider the lack of "registering" events and instead just running hook.Call with an arbitrary event name, that's not really feasible. It would be helpful, though, just breaking. :p
bw81@ulysses-forums ~ % whoami
Homepage