Ulysses
General => Developers Corner => Topic started by: lRoberth on October 07, 2018, 05:23:12 PM
-
I made a 3D2D screen where all users that are part of the staff team, are being shown there, but my problem, is that they're being shown by their user ID, when i want it to show by rank inheritance, and i can't find a way to do it that way.
here's what's happening:
(https://i.imgur.com/oUFQPKO.jpg)
i want it to appear like:
Fitz Simmons (Owner)
Bot01(Mod)
Hellfire377 (Trial-Mod)
any idea how i can do this?
-
You might be able to use groupInheritsFrom (http://ulyssesmod.net/docs/files/lua/ulib/shared/sh_ucl-lua.html#ucl.groupInheritsFrom) as a check each group - any returning another group, check it again until it returns false, that would then become the 'top' group. This would rely on you NOT having any tree 'branches' though. Once it checked a branch that wasn't inherited, it would be listed as top group again.
maybe also be able to use getInheritanceTree (http://ulyssesmod.net/docs/files/lua/ulib/shared/sh_ucl-lua.html#ucl.getInheritanceTree)
I'm unsure from the example if it lists "top" to "bottom" though.
-
just fixed this about 2 minutes ago, i did it this way:
get all online players
check if they're administrators or nah
if they're administrators:
create a table
check the K value from the table that specifies what ranks are administrators
return that K value
insert that K value into the table and also the player entity
draw by SortedPairs() from lower to higher value
done
(https://i.imgur.com/5EjLaCs.jpg)
might not be the better way, but definitely works without any problem
-
Good job.
One way may not be 'better' than another - you're doing with less complexity what my general idea was doing.
:)
-
Worth noting that another way to do it is with ply:CheckGroup(ply2:GetUserGroup()), which essentially does the same as running groupInheritsFrom() but in a smaller chunk of code. This is normally what I use in situations like this.