• Print

Author Topic: Ulx respawn  (Read 3685 times)

0 Members and 1 Guest are viewing this topic.

Offline Gigabait

  • Newbie
  • *
  • Posts: 13
  • Karma: -2
Ulx respawn
« on: October 20, 2015, 09:20:20 pm »
Hello, when I revived I can not attack what is problem?
Code: [Select]
local CATEGORY_NAME = "Deathrun"

function ulx.respawn( calling_ply, target_ply )
    if not target_ply:Alive() then
        target_ply:Spawn()
        ulx.fancyLogAdmin( calling_ply, true, "#A respawned #T", target_ply )
    end
end

local respawn = ulx.command( CATEGORY_NAME, "ulx respawn", ulx.respawn, "!respawn", true )
respawn:addParam{ type=ULib.cmds.PlayerArg }
respawn:defaultAccess( ULib.ACCESS_ADMIN )
respawn:help( "Respawns a player" )

Offline Timmy

  • Ulysses Team Member
  • Sr. Member
  • *****
  • Posts: 252
  • Karma: 168
  • Code monkey
Re: Ulx respawn
« Reply #1 on: October 21, 2015, 08:00:55 am »
The gamemode was most likely programmed to give players their loadout (weapons) when the round starts, not when the player spawns.

You can solve this by calling GM:PlayerLoadout() on your target after you spawn him.

Code: Lua
  1. local CATEGORY_NAME = "Deathrun"
  2.  
  3. function ulx.respawn( calling_ply, target_ply )
  4.     if not target_ply:Alive() then
  5.         target_ply:Spawn()
  6.         hook.Call( "PlayerLoadout", GAMEMODE, target_ply )
  7.         ulx.fancyLogAdmin( calling_ply, true, "#A respawned #T", target_ply )  
  8.     end
  9. end
  10.  
  11. local respawn = ulx.command( CATEGORY_NAME, "ulx respawn", ulx.respawn, "!respawn", true )
  12. respawn:addParam{ type=ULib.cmds.PlayerArg }
  13. respawn:defaultAccess( ULib.ACCESS_ADMIN )
  14. respawn:help( "Respawns a player" )

  • Print