Get a table of available commands for current rank in ULX?

How do I get the available commands for a ULX rank in LUA? I need to get a table of the available commands to a players current rank.

-snip- Sorry I read it wrong. I don’t know :confused:

I hope you appreciate this, I just had to try and navigate through ULX/ULIB source code for this. Because nothing is consistent in that mess of an admin mod try looping either of these: ulx.cmdsByCategory or ULib.sayCmds.

The actual command table is localized and has no method to expose it so… I hate ULX.

Agreed with every point there. This is a function I wrote a long time ago and didn’t comment at all, after a lot of swearing at ULX, when I finished it it felt wonderful. I’m pretty sure you give it a player and it gives you a list of commands they have access to…
[lua]
local function PrepareSayCmdTable(ply)

ply = IsValid(ply) and ply or nil
local canQuery = ply and true or false

local t = {}

local i = ULib.sayCmds
for cmd,props in pairs(i) do
	local v = {}
	v.chatcmd = cmd
	v.concmd = props.__cmd
	v.access = props.access
	v.plyAllowed = true
	if canQuery then
		v.plyAllowed = ULib.ucl.query(ply,v.access)
	end
	table.insert(t,v)
end

return t

end
[/lua]

You can easily do it by directly going to the group table and pulling the data. Here’s what I just whipped up which does exactly what you need:



concommand.Add("printgroupaccess", function()
	for k, v in pairs(ULib.ucl.groups['admin']['allow']) do
		print(v)
	end
end)


Does that get commands that are allowed by inheritance as well?

I’m not sure too be honest. I’ll give it a test now, if it doesn’t you can just go through the inheritance and add to the table you’re making. I’ll post back with results in a few minutes.

[editline]3rd January 2014[/editline]

Well, you’re right it doesn’t grab inherited commands. I did a check for inheritance and if it was, it would grab the inherited groups commands but if that group inherits commands it doesn’t grab them.

Tl;dr: your way works, mine doesn’t.

Perfect! Thanks :smiley: