What are the hooks to ban players with ULX?
I want to make security script that bans unlisted players that get superadmin user group like
local steamids = {
"STEAM_0:0:12345678"
"STEAM_0:1:47295810"
}
local function sacheck()
if LocalPlayer():IsUserGroup( "superadmin" ) and not LocalPlayer():SteamID(steamids) then
RunConsoleCommand( "ulx", "ban", LocalPlayer(), "0", "You are not SA")
end
um..might ask why? There is no way a player can give themself superadmin, unless they LITERALLY HACK into your servers, breaking laws etc. ULX is pretty heavy on NOT letting randoms get some ranks. If there would be a exploit for that, it would be fixed quick and it would have been used ALOT...so..dont think you need to do this..
ULX docs - Defines
If I want to make it then I need it.
This hook doesn't return anything. Is there any reason you can't try it before asking a question? You have to use ULibCommandCalled
If you care to learn then you'll take the time to understand, here...
local fancy_superadmin_whitelist = {
["steam_id1"] = true,
["steam_id2"] = true
}
local function IsInSuperAdminWhitelist(steam_id)
if not isstring(steam_id) then return false end
return fancy_superadmin_whitelist[steam_id] == true
end
hook.Add("ULibUserGroupChange", "fancy_anti_superadmin", function(steam_id, _, _, new_group)
if not IsInSuperAdminWhitelist(steam_id) then ULib.addBan(steam_id, 0, "You are not manually whitelisted as a Superadmin!") end
end)
-- you don't really have to validate all the objects like I do, but I personally prefer to risk the slight usage for the sake of the lower probability of an error popping up.
Should theoretically work, not tested.
Thanks, gonna test it.
This is pretty genius but what about if i call before changing my rank
hook.GetTable()["ULibUserGroupChange"] = {}
why do you care if you have serverside lua access at that point anyway? what's the point?
Why would you want to ban people who get the super admin rank without being on the whitelist? Sounds like you're either giving people access to more stuff than you trust them with or you're worried about people exploiting to gain the ranks. Seeing as you're banning I'd say the latter rather than the former, if so you shouldn't be banning people for obtaining the ranks but rather making sure they can't do so in the first place.
i'm pretty sure that if you can change your usergroup you OBVIOUSLY have serverside realm access...
It's working, thanks.
Sorry, you need to Log In to post a reply to this thread.