Created
July 28, 2016 07:23
-
-
Save NanoAi/4f4ee26fb760267c9e758775c748692e to your computer and use it in GitHub Desktop.
(Garry's Mod) Add ULX Support for Luadev.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
local cmds = {} | |
if ulx and ulx.cmdsByCategory and not aowl then | |
aowl = {} | |
function aowl.cmdExsits(cmd) | |
local t = ulx.cmdsByCategory['Luadev Commands'] or {} | |
if t and #t >= 1 then | |
for i=1,#t do | |
if t[i].cmd == cmd then return true end | |
end | |
end | |
return false | |
end | |
function aowl.AddCommand(cmd, callback, group) | |
if istable(cmd) then | |
for k,v in pairs(cmd) do | |
aowl.AddCommand(v,callback,group) | |
end | |
return | |
end | |
cmds = cmds or {} | |
cmds[cmd] = {callback = callback, group = group or "players", cmd = cmd} | |
for _,v in next, cmds do | |
local concmd = "ulx ld"..v.cmd | |
ulx.luadev = ulx.luadev or {} | |
ulx.luadev[v.cmd] = v.callback | |
if not aowl.cmdExsits(concmd) then | |
local com = ulx.command( "Luadev Commands", concmd, ulx.luadev[v.cmd], "!"..v.cmd ) | |
com:addParam{ type=ULib.cmds.StringArg, hint="script", ULib.cmds.takeRestOfLine } | |
com:defaultAccess( v.group == "developers" and ULib.ACCESS_SUPERADMIN or ULib.ACCESS_ALL ) | |
end | |
end | |
end | |
function aowl.TargetNotFound(trg) | |
local trg = tostring(trg) | |
if trg == "notarget" then | |
return "No target found or target was invalid." | |
else | |
return "The target <"..tostring(trg).."> was not found or was invalid." | |
end | |
end | |
end | |
if SERVER then include("autorun/server/luadev_chatcmds.lua") end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment