Author Topic: IsUserMore(group) or IsUserHigher(group)  (Read 3492 times)

0 Members and 1 Guest are viewing this topic.

Offline MrPresident

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 2728
  • Karma: 430
    • |G4P| Gman4President
IsUserMore(group) or IsUserHigher(group)
« on: April 04, 2008, 08:13:02 PM »
Jam and I were talking about this on steam and we decided that it would be a good idea for there to be a way to easily determine if a player is in a group that is in a higher level group that the one you pass it.

This would be a very effective way to determine if a user is in a registered group, rather than just in the user default group.

Considering everyone on the server is in the 'user' group, trying to find out if a user is in that group only is a bit tricky seeing as you can't use IsUserGroup("user") because they would return true always.

Right now, I can determine who these users are, but it is a bit tricky and hacky at best because I have to do something like:
Code: [Select]
if !ply:IsUserGroup("member") and !ply:IsUserGroup("vip") and !ply:IsUserGroup("gold") and !ply:IsUserGroup("platinum") and !ply:IsAdmin() then
     This user is not in any group
end
This works, but it would really only work on my server.

However, since all users return true for IsUserGroup("user") it would be useful to have a way to determine if a player was ONLY in this group or if a player was NOT only in that group.

This would make creating modules and functions limited to people who are in a group (since everyone has different group setups, my method wouldn't be too easy to make global) or denying certain things to people who are not in any groups besides user.


I know this might be confusing, I confused myself half way through writing this.. lol =)

Offline Chironex

  • Full Member
  • ***
  • Posts: 197
  • Karma: 11
  • Formerly known as Kyzer
Re: IsUserMore(group) or IsUserHigher(group)
« Reply #1 on: April 04, 2008, 10:28:15 PM »
If you use UTeam, you could use
Code: [Select]
ply:Team()

Ex:
Code: [Select]
if ply:Team() > UTeam.BASETEAMINDEX + 2    --he is not in superadmins group and not in admins group (with default UTeam setup)

But this will result as the same problem you have...people doesn't have same teams setup, and people doesn't all have UTeam

I am clueless then
« Last Edit: April 04, 2008, 10:31:36 PM by Kyzer »

Offline JamminR

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 8096
  • Karma: 390
  • Sertafide Ulysses Jenius
    • Team Ulysses [ULib/ULX, other fine releases]
Re: IsUserMore(group) or IsUserHigher(group)
« Reply #2 on: April 04, 2008, 11:01:34 PM »
I think logic would follow something like the following.
Pass group and player
Code: [Select]
for k, v in pairs( ULib.ucl.authed[ PLAYER_BEING_TESTED].groups ) do - cycle through player's groups.
                           --test here if group passed is == v
end

« Last Edit: April 04, 2008, 11:18:00 PM by JamminR »
"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: 6214
  • Karma: 394
  • Project Lead
Re: IsUserMore(group) or IsUserHigher(group)
« Reply #3 on: April 05, 2008, 10:13:47 AM »
I guess I should trash the IsUserGroup() passing back every group they belong to and instead only return the first, unless they pass the function 'true' for a param in which it would have the behavior it does now.

How about a better way to access inherited groups for IsUserHigher()? Not sure what you mean by IsUserMore().
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: IsUserMore(group) or IsUserHigher(group)
« Reply #4 on: April 05, 2008, 12:07:19 PM »
I guess I should trash the IsUserGroup() passing back every group they belong to and instead only return the first, unless they pass the function 'true' for a param in which it would have the behavior it does now.

How about a better way to access inherited groups for IsUserHigher()? Not sure what you mean by IsUserMore().

As for IsUserGroup passing only the one, that seems to be a good idea.
As for IsUserMore, it was late, and we kind of figured there wasn't a great way to determine that one group was 'higher' in rank/meaning than another.
Just because one custom group inherits another doesn't mean it's 'higher'. So, that was my idea... 'more' ... does the user exist in 'more' than just the specified group.
MrPresident was looking for an easy way to determine if someone was in more than just 'users' group.
« Last Edit: April 05, 2008, 12:08:57 PM by JamminR »
"Though a program be but three lines long, someday it will have to be maintained." -- The Tao of Programming