Author Topic: Help  (Read 191 times)

0 Members and 1 Guest are viewing this topic.

Offline UwU me no advertise

  • Newbie
  • *
  • Posts: 2
  • Karma: 0
Help
« on: June 13, 2020, 12:03:12 AM »
My commands won't work,  won't pop up in the xgui does not change anything. Ill paste the command below but sorry if it is trash i started lua yesterday.





Code: Lua
  1. CATEGORY_NAME "My Ulx Stuff"
  2. ------------------------------Reset------------------------------
  3. function ulx.reset( calling_ply, target_ply )
  4. if target_ply:IsFrozen() then -- Checks if target is frozen
  5.         ULib.tsayError ( calling_ply, v:Nick() .. " That boi is cold / frozen use !unfreeze to warm him up!"
  6.         if target_ply:Alive() then
  7.                 target_ply:Kill() -- Kill the player
  8.                 if not target_ply:Alive() then
  9.                         target_ply:Spawn() -- Respawns the player
  10.                 ulx.fancyLogAdmin( calling_ply, true "#a respawned #t"
  11.         end
  12. end
  13.  
  14.  
  15.  
  16. local reset = ulx.command( CATEGORY_NAME, "ulx reset", ulx.reset, "!reset" )
  17. reset:addParam{ type=ULib.cmds.PlayersArg }
  18. reset:defualtAccess( ULib.ACCESS_ADMIN )
  19. reset:help( "resets the selected target. " )

[EDIT] - Timmy Use BBCode to format code snippet.
« Last Edit: June 13, 2020, 01:51:35 AM by Timmy »

Offline Timmy

  • Ulysses Team Member
  • Full Member
  • *****
  • Posts: 246
  • Karma: 165
  • Code monkey
    • ULX Unofficial Documentation
Re: Help
« Reply #1 on: June 13, 2020, 03:21:06 AM »
Yes, your code has a few errors. A missing assignment operator on line 1, closing parenthesis on line 5 & 10, missing comma on line 10, ...

Trying to debug a lot of code at once is super hard, especially if you're just starting out.

Write a small part of your program, test it, then debug until it works. The errors in your console will usually tell you what went wrong. If you need help with a specific error, include the error message along with the code that's causing issues, in your forum post.

Here's a template to get you started. This should give you a working reset command that appears in XGUI:
Code: Lua
  1. -- lua/ulx/modules/sh/my-ulx-stuff.lua
  2. CATEGORY_NAME = "My Ulx Stuff"
  3.  
  4. function ulx.reset( calling_ply, target_ply )
  5.     ulx.fancyLogAdmin( calling_ply, "#A reset #T", calling_ply, target_ply )
  6. end
  7. local reset = ulx.command( CATEGORY_NAME, "ulx reset", ulx.reset, "!reset" )
  8. reset:addParam{ type=ULib.cmds.PlayerArg }
  9. reset:defaultAccess( ULib.ACCESS_ADMIN )
  10. reset:help( "resets the selected target. " )

Of course, it won't actually reset your target yet.
Next, try adding the code to respawn a player, and make sure that works.
Then prevent respawning players that are still alive, and make sure that works.
And so on...
« Last Edit: June 13, 2020, 04:13:12 AM by Timmy »

Offline UwU me no advertise

  • Newbie
  • *
  • Posts: 2
  • Karma: 0
Re: Help
« Reply #2 on: June 14, 2020, 11:47:32 AM »
Thank you, I was on a camping trip so i could not answer before i got home. I'll try ur tips. And i will definetlly post here again.