I've been screwing around with this where if a user is not in the white list table then it will ban them if they are set to superadmin, what is the best way to check the players rank when they are set to superadmin?
Take a look at this hook: [url]http://ulyssesmod.net/docs/files/lua/ulib/shared/defines-lua.html#ULibUserAccessChange[/url]
Here is what I have but its not working can you spot any problems?
[CODE]local IDS = {"STEAM_0:1:"}
local function CheckSID(ply, sid)
if (table.HasValue(IDS, sid)) then
print("Granted")
else
RunConsoleCommand("ulx ban ",debugPlayer:Name()," 0")end)
end
end
hook.Add("PlayerAuthed", "CheckSID", CheckSID) [/CODE]
[b]debugPlayer[/b] is not defined, use [b]ply[/b] aaaand you will ban everyone whos not in the list because you are not checking player for usergroup
OR use this [url]http://ulyssesmod.net/docs/files/lua/ulib/shared/defines-lua.html#ULibUserGroupChange[/url] as added a update or two ago.
[QUOTE=andreblue;52042454]OR use this [url]http://ulyssesmod.net/docs/files/lua/ulib/shared/defines-lua.html#ULibUserGroupChange[/url] as added a update or two ago.[/QUOTE]
I'll check this out when I get home thanks for the help I'll reply if I need anymore.
[editline]1st April 2017[/editline]
I rewrote this on my phone should it only ban the non authorized superadmins now?
[CODE]-- ply:IsSuperAdmin()
local IDS = {"STEAM_0:1:"}
local function CHECKRANK()
if ply:IsSuperAdmin() then
CheckSID()
else
-- DO NOTHING
end
local function CheckSID(ply, sid)
if (table.HasValue(IDS, sid)) then
-- DO NOTHING
else
RunConsoleCommand("ulx ban",ply:Name()," 0")end)
end
end
hook.Add("PlayerAuthed", "CHECKRANK", CHECKRANK)[/CODE]
This is not really working I have a timer hooked up to it.
[CODE]-- ply:IsSuperAdmin()
local IDS = {"STEAM_0:1:"}
local function CHECKRANK()
if ply:IsSuperAdmin() then
CheckSID()
else
-- DO NOTHING
end
local function CheckSID(ply, sid)
if (table.HasValue(IDS, sid)) then
-- DO NOTHING
else
RunConsoleCommand("ulx ban",ply:Name()," 0")end)
end
end
hook.Add("PlayerAuthed", "CHECKRANK", CHECKRANK)[/CODE]
You are missing an end on your function CHECKRANK. Also, for your RunConsoleCommand I would advise you using steamids instead of the names because if a player has another name as another one, it can get really messy. I can't check at the moment, but if I remember correctly, you need to seperate the arguments for your RunConsoleCommand seperately, for example "RunConsoleCommand("ulx", "ban", ply:Name(), 0)". For your CheckSID function I would just run the console command if they are not on the list, so instead of "if (table.HasValue(IDS, sid)) then do "if not (table.HasValue(IDS, sid)) then" and just remove the else. Here is how I would personally do it. There's no need for a seperate function to check if they are superadmin.
[code]local steamid_lookup = {
["STEAMID"] = true,
["STEAMID2"] = true
}
hook.Add("PlayerAuthed", "ULXIDCheck", function(ply, sid)
if not steamid_lookup[sid] and ply:IsSuperAdmin() then
RunConsoleCommand("ulx", "banid", ply:SteamID(), 0, "You are not on the Superadmin whitelist!.")
end
end)[/code]
[QUOTE=Matsumoto;52046139]You are missing an end on your function CHECKRANK. Also, for your RunConsoleCommand I would advise you using steamids instead of the names because if a player has another name as another one, it can get really messy. I can't check at the moment, but if I remember correctly, you need to seperate the arguments for your RunConsoleCommand seperately, for example "RunConsoleCommand("ulx", "ban", ply:Name(), 0)". For your CheckSID function I would just run the console command if they are not on the list, so instead of "if (table.HasValue(IDS, sid)) then do "if not (table.HasValue(IDS, sid)) then" and just remove the else. Here is how I would personally do it. There's no need for a seperate function to check if they are superadmin.
[code]local steamid_lookup = {
["STEAMID"] = true,
["STEAMID2"] = true
}
hook.Add("PlayerAuthed", "ULXIDCheck", function(ply, sid)
if not steamid_lookup[sid] and ply:IsSuperAdmin() then
RunConsoleCommand("ulx", "banid", ply:SteamID(), 0, "You are not on the Superadmin whitelist!.")
end
end)[/code][/QUOTE]
Okay thanks a ton Ill try this out right now.
Sorry, you need to Log In to post a reply to this thread.