ULX

Author Topic: Help with my ulx command.  (Read 2550 times)

0 Members and 1 Guest are viewing this topic.

Offline blackfire88

  • Jr. Member
  • **
  • Posts: 56
  • Karma: 0
Help with my ulx command.
« 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 :(

Offline Aaron113

  • Hero Member
  • *****
  • Posts: 803
  • Karma: 102
Re: Help with my ulx command.
« Reply #1 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.
« Last Edit: January 09, 2012, 06:03:03 PM by Aaron113 »

Offline JamminR

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 8096
  • Karma: 390
  • Sertafide Ulysses Jenius
    • Team Ulysses [ULib/ULX, other fine releases]
Re: Help with my ulx command.
« Reply #2 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.
"Though a program be but three lines long, someday it will have to be maintained." -- The Tao of Programming

Offline Aaron113

  • Hero Member
  • *****
  • Posts: 803
  • Karma: 102
Re: Help with my ulx command.
« Reply #3 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.