General > Developers Corner
Help with my ulx command.
(1/1)
blackfire88:
--- Code: ---function ulx.changetorp( calling_ply )
local curgame = GetConVarString("sv_gamemode")
local shouldbe = "darkrp"
if curgame = shouldbe then
ULib.tsayError( calling_ply, "Server is already in RP!" )
else
RunConsoleCommand("changegamemode", game.GetMap .. " darkrp")
ulx.fancyLogAdmin( calling_ply, "#A changed to RP." )
end
local changetorp = ulx.command( "Extras", "ulx changetorp", ulx.changetorp, "!changetorp" )
changetorp:defaultAccess( ULib.ACCESS_ADMIN )
changetorp:help( "Changes to RP" )
--- End code ---
Its not registering! What have I done wrong :(
Aaron113:
--- Code: ---function ulx.changetorp( calling_ply )
local curgame = GetConVarString("sv_gamemode")
local shouldbe = "darkrp"
if curgame = shouldbe then
ULib.tsayError( calling_ply, "Server is already in RP!" )
else
RunConsoleCommand("changegamemode", game.GetMap(), "darkrp")
ulx.fancyLogAdmin( calling_ply, "#A changed to RP." )
end
end
local changetorp = ulx.command( "Extras", "ulx changetorp", ulx.changetorp, "!changetorp" )
changetorp:defaultAccess( ULib.ACCESS_ADMIN )
changetorp:help( "Changes to RP" )
--- End code ---
Fixed - You forgot an end.
JamminR:
Also game.GetMap should be game.GetMap()
Have to watch that syntax :)
Wouldn't a better command argument be
RunConsoleCommand("changegamemode", game.GetMap(), "darkrp") ?
According to the Gmod wiki, its runconsolecommand(command, parm1, parm2) -
Seems using concatenation ".." isn't optimal if a command allows for multiple parameters.
Aaron113:
Ahh yeah... modified my post with those as well. I didn't double check for more errors.
Navigation
[0] Message Index
Go to full version