Ulysses

General => Developers Corner => Topic started by: StaTiiKxKALEB on June 15, 2016, 05:06:35 PM

Title: Ban not adding.
Post by: StaTiiKxKALEB 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)
Title: Re: Ban not adding.
Post by: Bytewave on June 15, 2016, 06:42:36 PM
Presumably you should be using ULib.ban(ply[, time][, reason][, admin]) (http://ulyssesmod.net/docs/files/lua/ulib/server/player-lua.html#ban) instead of ULib.addBan() (http://ulyssesmod.net/docs/files/lua/ulib/server/player-lua.html#addBan), but I'm not sure.
Title: Re: Ban not adding.
Post by: JamminR on June 15, 2016, 06:43:34 PM
PlayerDisconnectED (https://wiki.garrysmod.com/page/GM/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.
Title: Re: Ban not adding.
Post by: JamminR 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.
Title: Re: Ban not adding.
Post by: StaTiiKxKALEB on June 15, 2016, 06:48:39 PM
PlayerDisconnectED (https://wiki.garrysmod.com/page/GM/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" )
Title: Re: Ban not adding.
Post by: JamminR 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 (http://ulyssesmod.net/docs/files/lua/ulib/server/ucl-lua.html#ucl.addUser)
Title: Re: Ban not adding.
Post by: MrPresident 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.
Title: Re: Ban not adding.
Post by: JamminR 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"
Title: Re: Ban not adding.
Post by: Bytewave 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