ULX

Author Topic: Command requires save to work??  (Read 169 times)

0 Members and 1 Guest are viewing this topic.

Offline TheTrustySword

  • Newbie
  • *
  • Posts: 2
  • Karma: 0
Command requires save to work??
« on: January 20, 2019, 08:48:49 AM »
Hello,

So I created a custom ULX command, quite a few actually, and I'm having one of the strangest issues I've ever encountered. For some reason one of my commands pops up with an error (saying target_ply is a nil value). I have assigned it with the PlayerArg. But to fix it I have to open the file and press save. Then it runs perfectly fine. All the other commands in this file work fine and I wrote them in the exact same way. Anyone have any suggestions or help? I can't really open the file and save it every time..

Here is the format I used for the command which does not work.
Code: [Select]
function ulx.supercoolcommand(calling_ply,target_ply)
target_ply:SendLua([[RunConsoleCommand("super_cool_command")]])
ulx.fancyLogAdmin( calling_ply, "#A did something super cool to #T", target_ply )
end
local supercoolcommand = ulx.command("Some Super Cool Stuff", "ulx supercoolcommand", ulx.supercoolcommand, "!supercoolcommand")
supercoolcommand:addParam{ type=ULib.cmds.PlayerArg }
supercoolcommand:defaultAccess( ULib.ACCESS_ADMIN )
supercoolcommand:help( "Does something super cool." )

Offline MrPresident

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 2690
  • Karma: 418
    • |G4P| Gman4President
Re: Command requires save to work??
« Reply #1 on: January 20, 2019, 09:24:48 AM »
Without seeing the exact code and stack trace from your error, this is only speculation... but..

it sounds like you have something in another file that is named the same and therefore overwriting your custom command or a variable used in it.

Opening and saving the file (while your server is running) causes gmod to hotload that file and the definitions in that file become what is being used.

Not sure the best way to go about checking for that... you would need to open up any custom files you have and make sure you didn't use the same names. Copy/Paste can cause this if you forget to rename something.

Offline TheTrustySword

  • Newbie
  • *
  • Posts: 2
  • Karma: 0
Re: Command requires save to work??
« Reply #2 on: January 20, 2019, 10:08:32 AM »
Thank you for the help. At least this now makes sense to me. I will have a look and get back to you!