ULX

Author Topic: ulx rank reading  (Read 7848 times)

0 Members and 1 Guest are viewing this topic.

Offline gorgorp

  • Newbie
  • *
  • Posts: 4
  • Karma: 0
ulx rank reading
« 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

Offline gorgorp

  • Newbie
  • *
  • Posts: 4
  • Karma: 0
Re: ulx rank reading
« Reply #1 on: August 08, 2009, 08:20:16 AM »
could someone please help me

Offline gorgorp

  • Newbie
  • *
  • Posts: 4
  • Karma: 0
Re: ulx rank reading
« Reply #2 on: August 08, 2009, 08:28:41 AM »
nvm i figured out

Offline Megiddo

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 6213
  • Karma: 394
  • Project Lead
Re: ulx rank reading
« Reply #3 on: August 08, 2009, 10:43:59 AM »
In ULib, is player:GetGroups(). I'm not aware of any default gmod implementation to do the same thing.
Experiencing God's grace one day at a time.

Offline JamminR

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 8096
  • Karma: 390
  • Sertafide Ulysses Jenius
    • Team Ulysses [ULib/ULX, other fine releases]
Re: ulx rank reading
« Reply #4 on: August 08, 2009, 08:38:04 PM »
Megiddo, though ULib has enhanced functionality, I'm pretty sure he probably found IsAdmin, IsSuperadmin, and IsUserGroup from the standard Gmod lua.
"Though a program be but three lines long, someday it will have to be maintained." -- The Tao of Programming

Offline jay209015

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 934
  • Karma: 62
    • Dev-Solutions
Re: ulx rank reading
« Reply #5 on: August 09, 2009, 12:24:19 PM »
I use this to get a players group:
Code: [Select]
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
An error only becomes a mistake when you refuse to correct it. --JFK

"And thus the downfall of the great ULX dynasty was wrought not by another dynasty, but the slow and steady deterioration of the leaders themselves, followed by the deprecation of the great knowledge they possessed." -Gmod, Chapter 28, verse 34 -- Stickly

Offline JamminR

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 8096
  • Karma: 390
  • Sertafide Ulysses Jenius
    • Team Ulysses [ULib/ULX, other fine releases]
Re: ulx rank reading
« Reply #6 on: August 09, 2009, 12:37:57 PM »
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?
"Though a program be but three lines long, someday it will have to be maintained." -- The Tao of Programming

Offline Megiddo

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 6213
  • Karma: 394
  • Project Lead
Re: ulx rank reading
« Reply #7 on: August 09, 2009, 01:03:33 PM »
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.
Experiencing God's grace one day at a time.

Offline JamminR

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 8096
  • Karma: 390
  • Sertafide Ulysses Jenius
    • Team Ulysses [ULib/ULX, other fine releases]
Re: ulx rank reading
« Reply #8 on: August 09, 2009, 05:59:03 PM »
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.
"Though a program be but three lines long, someday it will have to be maintained." -- The Tao of Programming

Offline Megiddo

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 6213
  • Karma: 394
  • Project Lead
Re: ulx rank reading
« Reply #9 on: August 09, 2009, 06:08:05 PM »
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.
Experiencing God's grace one day at a time.

Offline jay209015

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 934
  • Karma: 62
    • Dev-Solutions
Re: ulx rank reading
« Reply #10 on: August 09, 2009, 08:16:25 PM »
Wouldn't the easiest way of determing a users actual highest rank be the rank that has the highest amount of allows, including inheritance?
An error only becomes a mistake when you refuse to correct it. --JFK

"And thus the downfall of the great ULX dynasty was wrought not by another dynasty, but the slow and steady deterioration of the leaders themselves, followed by the deprecation of the great knowledge they possessed." -Gmod, Chapter 28, verse 34 -- Stickly

Offline JamminR

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 8096
  • Karma: 390
  • Sertafide Ulysses Jenius
    • Team Ulysses [ULib/ULX, other fine releases]
Re: ulx rank reading
« Reply #11 on: August 09, 2009, 08:36:32 PM »
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.
« Last Edit: August 09, 2009, 08:39:11 PM by JamminR »
"Though a program be but three lines long, someday it will have to be maintained." -- The Tao of Programming

Offline gorgorp

  • Newbie
  • *
  • Posts: 4
  • Karma: 0
Re: ulx rank reading
« Reply #12 on: August 10, 2009, 01:52:56 AM »
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

Offline JamminR

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 8096
  • Karma: 390
  • Sertafide Ulysses Jenius
    • Team Ulysses [ULib/ULX, other fine releases]
Re: ulx rank reading
« Reply #13 on: August 10, 2009, 02:54:52 PM »
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.
"Though a program be but three lines long, someday it will have to be maintained." -- The Tao of Programming