General > Developers Corner
ulx rank reading
jay209015:
I use this to get a players group:
--- Code: ---function URestrict.GetUserGroup( ply )
for k, v in pairs( ULib.ucl.authed[ ply ].groups ) do
if v ~= ULib.ACCESS_ALL then
return v
else
return "user"
end
end
end
--- End code ---
JamminR:
Jay, I've often wondered, and Megiddo may have more insight, would that return the 'highest' level of access that the person has? If they were a custom group such as Elite, that inherited Respected, which inheritied Member below it - would doing it that way always return 'Elite?
Which leads to another question regarding optimization;
Rather than going through a for loop of the .groups - would it be possible to just return ULib.ucl.authed[ ply ].groups[ <1?> ] ??
Would 1 always be the "highest" rank, and if so, wouldn't a table lookup like that be quicker than the for loop?
Megiddo:
Looks like he's just returning the first value he comes across. You wouldn't want to return the group at index 1 because I think depending on how the file is setup, it may or may not be the number 1 and may instead be the string "1". I think that was fixed when we made our own file parser instead of using garry's, but I'm not sure.
JamminR:
So in essence, Jay's way of grabbing the 'highest' rank isn't guaranteed?
Though I know Player:query could be used to test for a specific command access, if I wanted to write a script (or in my case, already have an unfinished one not worked on in year(s)) that returned the highest group at the top of the inheritance chain as listed in example above.... is there a ULib command to do it?
If not directly, how would you check?
This was a challenge I was having with UMotd returning the 'high' group of any non-standard groups.
Elite/Respected/Member/Minge etc.
Megiddo:
There is no easy way, you'd have to traverse the ULib.ucl table to figure it out. Sorry. :P
I'm thinking of recoding UCL though (as I've had it on my todo list since nearly the beginning of time), so this would definitely be something I'd improve.
Navigation
[0] Message Index
[#] Next page
[*] Previous page
Go to full version