• Print

Author Topic: Trigger ULX Command with Command  (Read 4320 times)

0 Members and 1 Guest are viewing this topic.

Offline BLEEP_BLOOP

  • Newbie
  • *
  • Posts: 14
  • Karma: 1
Trigger ULX Command with Command
« on: February 23, 2015, 07:01:23 pm »
I am trying to make a simple code that allows me to do !build in-game to put the player in god and !kill to ungod the player. This is what I got so far:

Code: [Select]
local CATEGORY_NAME = "Utility"

timer.Create( "build", .3, 1, function( target_plys )
if Player:Alive() then
    RunConsoleCommand( "ulx god", Player:Name() ) end
end )
end

timer.Create( "kill", .3, 1, function( target_plys )
        RunConsoleCommand( "ulx ungod", playername) end
end )
end
)

It throws out the error: '<eof>' expected near 'end'. Can someone please explain why? Any help would be appreciated.

Thanks,
BLEEP_BLOOP :D

Offline Bytewave

  • Respected Community Member
  • Hero Member
  • *****
  • Posts: 718
  • Karma: 116
  • :)
    • My Homepage
Re: Trigger ULX Command with Command
« Reply #1 on: February 23, 2015, 07:47:42 pm »
I've found a couple of things wrong:

Code: Lua
  1. function( target_plys )
  2.         if Player:Alive() then
  3.                 RunConsoleCommand( "ulx god", Player:Name() ) end
  4.         end )
  5. end
Code: Lua
  1. function( target_plys )
  2.         RunConsoleCommand( "ulx ungod", playername) end
  3. end )
  4. )
All these arbitrarily placed "end"s. That's breaking it, right there.
Try this instead:
Code: Lua
  1. function( target_plys )
  2.         if Player:Alive() then
  3.                 RunConsoleCommand("ulx god", Player:Name())
  4.         end
  5. end)
Code: Lua
  1. function( target_plys )
  2.         RunConsoleCommand( "ulx ungod", playername)
  3. end)

Code: Lua
  1. RunConsoleCommand( "ulx ungod", playername)
That's not how RunConsoleCommand works.
Code: Lua
  1. RunConsoleCommand("ulx", "ungod", ply:Name())
is how it should be.

That's not all your code, is it? Because that definitely won't make you a ULX command.
« Last Edit: February 23, 2015, 07:50:02 pm by Bytewave »
bw81@ulysses-forums ~ % whoami
Homepage

Offline XxLMM13xX

  • Sr. Member
  • ****
  • Posts: 265
  • Karma: -51
  • New to lua development
    • Twitch
Re: Trigger ULX Command with Command
« Reply #2 on: February 24, 2015, 02:14:24 pm »
You could copy the god code from the ULX file and then just change the name/command!

  • Print