Ulysses Stuff > General Chat & Help and Support
Restricting Players by their group.
spbogie:
Ah, perhapse the PlayerSpawnObject hook doesn't have a return value. (There is no documentation for it, I just know it gets called on anything they spawn).
The for loop should still work, and CanTool can point to the same function as the PlayerSpawn* hooks since all you need is the ply argument whic is first on both.
--- Code: ---if not SERVER then return end
local groups = { "superadmin", "admin", "opperator" } --Add your groups here
local function block_build( ply )
for _,v in groups do
if ply:IsUserGroup( v ) then
return
end
end
ULib.tsay( ply, "You are not allowed to build." )
return false
end
hook.Add( "PlayerSpawnProp", "block_prop", block_build )
hook.Add( "PlayerSpawnEffect", "block_effect", block_build )
hook.Add( "PlayerSpawnVehicle", "block_vehicle", block_build )
hook.Add( "PlayerSpawnSENT", "block_sent", block_build )
hook.Add( "CanTool", "block_tool", block_build )
--- End code ---
Try that (slightly more efficient).
cold12141:
Error was something to do with the table.
[EDIT] Cold, I've split your post. See Developers Corner - Custom ULX AddTrustee code Explanation (and help with your code!) there.
spbogie:
Oops, forgot about the ipairs (I've been working with Python too much lately.)
--- Code: ---if not SERVER then return end
local groups = { "superadmin", "admin", "opperator" } --Add your groups here
local function block_build( ply )
for _,v in ipairs( groups ) do
if ply:IsUserGroup( v ) then
return
end
end
ULib.tsay( ply, "You are not allowed to build." )
return false
end
hook.Add( "PlayerSpawnProp", "block_prop", block_build )
hook.Add( "PlayerSpawnEffect", "block_effect", block_build )
hook.Add( "PlayerSpawnVehicle", "block_vehicle", block_build )
hook.Add( "PlayerSpawnSENT", "block_sent", block_build )
hook.Add( "CanTool", "block_tool", block_build )
--- End code ---
That should work now. (hopefully ::))
Navigation
[0] Message Index
[*] Previous page
Go to full version