Ulysses

General => Developers Corner => Topic started by: blackfire88 on January 09, 2012, 02:30:53 PM

Title: Help with my ulx command.
Post by: blackfire88 on January 09, 2012, 02:30:53 PM
Code: [Select]
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" )

Its not registering! What have I done wrong :(
Title: Re: Help with my ulx command.
Post by: Aaron113 on January 09, 2012, 05:39:07 PM
Code: [Select]
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" )

Fixed - You forgot an end.
Title: Re: Help with my ulx command.
Post by: JamminR on January 09, 2012, 05:56:59 PM
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.
Title: Re: Help with my ulx command.
Post by: Aaron113 on January 09, 2012, 06:03:33 PM
Ahh yeah... modified my post with those as well. I didn't double check for more errors.