General > Developers Corner
Is this how to properly restrict the spawn and context menus to certain ranks?
VORTEXGaming:
--- Code: ---if SANDBOX:SpawnMenuOpen() then
function checkULX(ply)
if table.HasValue({"owner", "dev", "superadmin"}, ply:GetNWString("usergroup")) then
return true
else return false
end
end
if GM:ContextMenuOpen() then
function checkULX(ply)
if table.HasValue({"owner", "dev", "superadmin"}, ply:GetNWString("usergroup")) then
return true
else return false
end
end
--- End code ---
BlueNova:
Do you mean the auto pop up motd menu?
VORTEXGaming:
Look at the title
JamminR:
In simplest answer, no, that is not correct.
SANDBOX:SpawnMenuOpen and GM:ContextMenuOpen are HOOKS.
You monitor for hooks using hook.Add
Add hook looks for the events you want, and then calls a function passing some information, usually the player that caused the event.
You could write functions to then check the player's group and return false if they were not a member of your groups you want.
You'd also likely want to check, the way you're currently checking, using ULib's GetUserGroup.
I'm not sure your GetNW string would work consistently or at all.
If you don't use ULib, unfortunately, GMod's closest check is Player:IsUserGroup. With that, you'd have to do a for loop through your table checking if player was part of the table.
Alpha Universe:
@JamminR What is the correct Code then?
Navigation
[0] Message Index
[#] Next page
Go to full version