Ulysses

General => Developers Corner => Topic started by: jay209015 on July 09, 2008, 08:36:40 PM

Title: ULib groups
Post by: jay209015 on July 09, 2008, 08:36:40 PM
What is the name of the table that the ULib groups are stored under?

==EDIT==

Found it in the defines.lua file.
Title: Re: ULib groups
Post by: jay209015 on July 09, 2008, 09:08:48 PM
What I was looking for is a way to get a full list of allows for each group.
Title: Re: ULib groups
Post by: JamminR on July 10, 2008, 04:26:24 PM
You may have already found your answers, but I'll answer what I think it would be for anyone else that stumbles here.

ucl.groups[ <group_your_checking> ].allow

Pseudo-non checked lua code - I trust I'll be corrected.

for a, check_group in pairs (ucl.groups) do
    for b, each_allow in pairs ( ucl.groups( check_group ).allow ) do
-- Msg/Print/Whatever ( each_allow )
    end
end
Title: Re: ULib groups
Post by: jay209015 on July 11, 2008, 01:06:29 AM
PrintTable(ucl.groups) returned nil :S
Title: Re: ULib groups
Post by: Megiddo on July 11, 2008, 04:59:33 AM
ULib.ucl.groups silly :P
Title: Re: ULib groups
Post by: JamminR on July 11, 2008, 03:54:40 PM
See, knew I'd be corrected!
I missed that ULib. detail. :P
Title: Re: ULib groups
Post by: jay209015 on July 11, 2008, 10:11:42 PM
Is there a table that has the full list of allows, including the ones that are inherited? Like:
 Default, Superadmin has 16, Admin 80, and operator 1

Admin inherits from operator, and superadmin inherits from admin, so that means Superadmin really has 97 and admin has 81.

Right now I'm using this little script to do the job, just wondering if the was an easier way.

Code: [Select]
// UGroup
USort_Temp = 0
UGroups = {}
UpdateAllows = true
for k,v in pairs(ULib.ucl.groups) do
table.insert(UGroups, k )
end
UAllows = {}
for k,v in pairs(UGroups) do
UAllows[v] = #ULib.ucl.groups[v]["allow"]
end

UInherits = {}
function UpdateAllows()
for k,v in pairs(UGroups) do
UInherits[v] = ULib.ucl.groups[v]["inherit_from"]
if #UInherits[v] > 0 then
for k2,v2 in pairs(ULib.ucl.groups[v]["inherit_from"]) do
UAllows[v] = UAllows[v] + UAllows[v2]
if not UInherits[v2] == nil then
UpdateAllows = true
else
UpdateAllows = false
end
end
end
end
if UpdateAllows then
UpdateAllows()
end
end
UpdateAllows()

I'm working on a script so that you can type: UPromote <player>, and it will promote them to the next level :D