General > Developers Corner
ply:isUserGroup advice
Tomzen:
Hello, instead of using a password for my "ServerMode" (thanks to JamminR for the reminder), I would be using ply:isUserGroup, but I was wondering wether you could use a code like this for example:
--- Code: ---RANKS = {"admin","owner"}
if not ply:isUserGroup( RANKS ) then
ply:kick( "bleh" )
end
--- End code ---
or would this not work:
--- Code: --- ply:isUserGroup( RANKS )
--- End code ---
and I would have to use:
--- Code: ---ply:isUserGroup("admin") or ply:isUserGroup("owner") then ...
--- End code ---
Help here would help a lot :P
Thanks.
Zmaster:
I did something like this for an addon I made for a friend a while ago
Although I never tried using an if statement like that, I'm 99% sure that won't work
Here's how I would do it while still using tables like you are
table.HasValue
Player:GetUserGroup
MrPresident:
It would return an error.
"string expected ... returned table"
The proper way to do it, would be as Zmaster states. Use those 2 functions to create your check.
Tomzen:
Thanks Zmaster, another question:
How would I get it to ONLY activate when "maintenance mode" is activated, the only way I could think of is to create a ulx command that changes a variable to true or something... like "active = true", but when a map is changed, or server restarted this would be reset back to false wouldn't it?
example:
--- Code: --- function playerJoin( ply )
if active == true then
...
--- End code ---
but as I said, if the map has changed or server restarted then the "active" would be reset back to false
Aaron113:
http://wiki.garrysmod.com/page/gameevent/Listen
https://github.com/Nayruden/Ulysses/blob/052983fb132af59859784d3d6320ccdba01fe802/ulib/lua/ulib/server/ucl.lua#L562-L573
That is literally everything you need to do this. It won't even let them download files.
I got ninja'd, but for the mode being saved, you could just create a cvar or save to a data file.
Navigation
[0] Message Index
[#] Next page
Go to full version