Ulysses

General => Developers Corner => Topic started by: LuaTenshi on August 18, 2013, 11:48:31 PM

Title: ULX Context Menu
Post by: LuaTenshi on August 18, 2013, 11:48:31 PM
So I have made it so if your right click on a player (while in Context mode), you will get some more options...

Code: [Select]
/*-------------------------------------------------------------------------------------------------------------------------
ULX Context Menu || ulx.cmdsByCategory["Utility"][i]["cmd"]
-------------------------------------------------------------------------------------------------------------------------*/
local UsefullCommandsTable = {
"ulx kick",
"ulx ban",
"ulx spectate",
"ulx noclip"
}
for i=1, #UsefullCommandsTable do
local cmd = UsefullCommandsTable[i]
properties.Add("C_" .. string.upper(string.Replace(cmd, " ", "")),
{
MenuLabel = cmd,
Order = 2005 + i,
PrependSpacer = ( i == 1 ),
MenuIcon = "icon16/cog.png",

Filter = function(self, ent, ply)
if not IsValid(ent) then return false end
if( table.HasValue( player.GetAll(), ent ) ) then
return ply:query( "ulx _mcontext" ) -- THE CODE WONT WORK AS IS, THIS MUST BE CREATED TO CHECK IF THE USER HAS PERMISION TO USE THE MENU.
else
return false
end
end,

Action = function(self, ent)
LocalPlayer():ConCommand(cmd .. " $" .. tostring(ent:UserID()))
end
})
end

This is not a release, how ever if you want to use the code you can. The only real problem is that the Context menu is limited by range, and allot of ULX commands would have to be filtered from it...