Ulysses
General => Developers Corner => Topic started by: gorgorp on August 08, 2009, 03:55:20 AM
-
how do i with lua read what rank a user has like
if ply:HasPriv("superadmin")
or what ever you can
-
could someone please help me
-
nvm i figured out
-
In ULib, is player:GetGroups(). I'm not aware of any default gmod implementation to do the same thing.
-
Megiddo, though ULib has enhanced functionality, I'm pretty sure he probably found IsAdmin, IsSuperadmin, and IsUserGroup from the standard Gmod lua.
-
I use this to get a players group:
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
-
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?
-
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.
-
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.
-
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.
-
Wouldn't the easiest way of determing a users actual highest rank be the rank that has the highest amount of allows, including inheritance?
-
Many cases, yes, but not always.
Theoretically, as soon as we tried to depend on that method, some ULX user would have his so tweaked, he'd be granting "Elite" (using my previous examples) access to 'Respected', then denying them something because they were considered a different team or something.
Though a reasonable suggestion, it's just not foolproof that I can think of.
-
well as i said before i figured it out
function GetGroupUser( 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
-
gorgorp, problem is, that I've been asking about;
That method isn't 100% guaranteed to return the 'highest' rank of a ULib group chain.
Might most of the time, but no guarantees.