• Print

Author Topic: My command makes the category disappear  (Read 4971 times)

0 Members and 1 Guest are viewing this topic.

Offline zang

  • Newbie
  • *
  • Posts: 3
  • Karma: 0
My command makes the category disappear
« on: October 11, 2014, 06:54:21 pm »
Code: Lua
  1. function ulx.respawn ( calling_ply, target_ply )
  2.        
  3.         for i=1, #target_ply do
  4.                 local v = target_ply[ i ]
  5.        
  6.                 if (v:Team() == TEAM_GUARD_DEAD) then
  7.                                 v:SetTeam(TEAM_GUARD)
  8.                                 v:Alive
  9.                                
  10.                         elseif (v:Team() == TEAM_PRISONER_DEAD) then
  11.                                 v:SetTeam(TEAM_PRISONER)
  12.                                 v:Alive
  13.                         ulx.fancyLogAdmin( calling_ply, true, "#A respawned #T", target_ply )
  14.                         end
  15.   end
  16. end
  17. local respawn = ulx.command( CATEGORY_NAME, "ulx respawn", ulx.respawn, "!respawn", false )
  18. respawn:addParam{ type=ULib.cmds.PlayersArg }
  19. respawn:defaultAccess( ULib.ACCESS_ADMIN )
  20. respawn:help ( "Respawns a player" )

When i join the game whatever category i put this into doesn't appear in the ulx menu.
« Last Edit: October 11, 2014, 06:55:54 pm by zang »

Offline Zmaster

  • Full Member
  • ***
  • Posts: 235
  • Karma: 25
Re: My command makes the category disappear
« Reply #1 on: October 11, 2014, 06:59:27 pm »
Alive() checks to see if the player is alive or not and returns true or false
You'd use Spawn()

(Also, I see you have v:Alive in your code, make sure you have the () at the end of that too (after changing Alive to Spawn, obviously))
« Last Edit: October 11, 2014, 07:01:46 pm by Zmaster »

Offline zang

  • Newbie
  • *
  • Posts: 3
  • Karma: 0
Re: My command makes the category disappear
« Reply #2 on: October 11, 2014, 07:23:03 pm »
I did this, now it doesn't change their team, but it does move them to a different spawn location.
This is for Chessnut's Jailbreak gamemode by the way.
« Last Edit: October 11, 2014, 07:26:56 pm by zang »

Offline Zmaster

  • Full Member
  • ***
  • Posts: 235
  • Karma: 25
Re: My command makes the category disappear
« Reply #3 on: October 11, 2014, 08:09:54 pm »
On line 1 of that code, there's an space that will break it
where you have: ulx.respawn (calling_ply, target_ply )
it should say: ulx.respawn( calling_ply, target, ply )
In other words, remove the space inbetween ulx.respawn and the (

Also, if you have that code in it's own file and never set CATEGORY_NAME to something, it won't create a category for it (or put the command into one) - I think

Tried to fix it on my own and ended up with this code:
Code: Lua
  1. function ulx.respawn( calling_ply, target_ply )
  2.         if (target_ply:Team() == TEAM_GUARD_DEAD) then
  3.                 target_ply:SetTeam(TEAM_GUARD)
  4.                 target_ply:Spawn()
  5.                 ulx.fancyLogAdmin( calling_ply, true, "#A respawned #T", target_ply )
  6.         elseif (target_ply:Team() == TEAM_PRISONER_DEAD) then
  7.                 target_ply:SetTeam(TEAM_PRISONER)
  8.                 target_ply:Spawn()
  9.                 ulx.fancyLogAdmin( calling_ply, true, "#A respawned #T", target_ply )
  10.         end
  11. end
  12.  
  13. local respawn = ulx.command( "RespawnMe", "ulx respawn", ulx.respawn, "!respawn", false )
  14. respawn:addParam{ type=ULib.cmds.PlayerArg }
  15. respawn:defaultAccess( ULib.ACCESS_ADMIN )
  16. respawn:help( "Respawns a player" )

The command shows up in the list and somewhat works
I made myself a guard then killed myself mid-round (with a bunch of bots so the round wouldn't end) then I tried to use the command and I was teleported to a starting point but I was still a spectator
Almost as if it tried to spawn me but the gamemode wouldn't let it

Try checking through the gamemode files and see if you can find anything about that
For example, I tried making a command similar to this (but for PointShop and on TTT)
I had the same problem (being teleported to a spawn location, but not spawning)
For TTT, I had to use v:SpawnForRound( true )
This gamemode might require something similar
Here's the link for that thread if you want to read it: /index.php/topic,7446.0.html

Offline zang

  • Newbie
  • *
  • Posts: 3
  • Karma: 0
Re: My command makes the category disappear
« Reply #4 on: October 11, 2014, 09:53:53 pm »
Thanks you've been a big help

  • Print