Jump to content

[HELP] I can't respawn my Player


Recommended Posts

local team = getPlayerTeam ( source ) 
local heath = getElementHealth (getLocalPlayer ()) 
function respawn () 
if ( team ) then 
    local teamName = getTeamName ( team )  
    if (teamName == "Assasin") and heath =<0 then 
spawnPlayer (spawnPlayer, source, 0, 0, 5, 0, math.random (0,288), 0, 0, spawnTeam) 
outputChatBox("Bạn đã được respawn", source, 255,0,0) 
giveWeapon(8,1) 
giveWeapon(1,1) 
elseif ( teamName == "Gunner" ) then  
spawnPlayer (spawnPlayer, source, 0, 0, 5, 0, math.random (0,288), 0, 0, spawnTeam) 
outputChatBox("Bạn đã được respawn", source, 255,0,0) 
end 
end 
end 
addEventHandler("onClientResourceStart", root, respawn) 
  
  

Link to comment
local heath = getElementHealth ( source ) 
local playerTeam = getPlayerTeam ( source ) 
function respawn () 
 if ( getTeamName(playerTeam) == "Assasin" ) and health < 0 then 
setElementPosition ( source, 0, 0, 5, 0, math.random (0,288), 0, 0, spawnTeam) 
outputChatBox("B?n dã du?c respawn", source, 255,0,0) 
giveWeapon(8,1) 
giveWeapon(1,1) 
else 
if ( getTeamName(playerTeam) == "Gunner" ) then 
setElementPosition ( source, 0, 0, 5, 0, math.random (0,288), 0, 0, spawnTeam) 
outputChatBox("B?n dã du?c respawn", source, 255,0,0) 
           end 
        end 
     end 
addEventHandler("onClientResourceStart", root, respawn) 

Tried that in Client-Side, outputs no errors.

Edited by Guest
Link to comment
local team = getPlayerTeam(player) 
local health = getElementHealth(player) 
function respawn() 
      if team then 
          if (getTeamName(team) == "Assasin") and health <0 then 
              spawnPlayer(source, 0, 0, 5, 0,  math.random(0, 288), 0, 0,  spawnTeam) 
              outputChatBox("Bạn đã được respawn", source, 255, 0, 0) 
              giveWeapon(source, 8, 1) 
              giveWeapon(source, 1, 1) 
       elseif (getTeamName(team) == "Gunner") then 
               spawnPlayer(source, 0, 0, 5, 0, math.random(0, 288), 0 ,0 spawnTeam) 
               outputChatBox("Bạn đã được respawn", source, 255, 0, 0) 
      end 
   end 
end 
addEventHandler("onResourceStart", root, respawn) 

Edited by Guest
Link to comment

It says like getPlayerTeam etc,

However, if you do this Client-Side -

No errors are outputted :)

local team = getPlayerTeam(player) 
local health = getElementHealth(player) 
function respawn() 
      if team then 
          if (getTeamName(team) == "Assasin") and health <0 then 
              spawnPlayer(source, 0, 0, 5, 0,  math.random(0, 288), 0, 0,  spawnTeam) 
              outputChatBox("Bạn đã được respawn", source, 255, 0, 0) 
              giveWeapon(source, 8, 1) 
              giveWeapon(source, 1, 1) 
       elseif (getTeamName(team) == "Gunner") then 
               spawnPlayer(source, 0, 0, 5, 0, math.random(0, 288), 0 ,0 spawnTeam) 
               outputChatBox("Bạn đã được respawn", source, 255, 0, 0) 
      end 
   end 
end 
addEventHandler("onClientResourceStart", root, respawn) 

Link to comment

try this is server side:

local team = getPlayerTeam(player) 
local health = getElementHealth(player) 
function respawn() 
      if team then 
          if (getTeamName(team) == "Assasin") and health <0 then 
              spawnPlayer(source, 0, 0, 5, 0,  math.random(0, 288), 0, 0,  spawnTeam) 
              outputChatBox("Bạn đã được respawn", source, 255, 0, 0) 
              giveWeapon(source, 8, 1) 
              giveWeapon(source, 1, 1) 
       elseif (getTeamName(team) == "Gunner") then 
               spawnPlayer(source, 0, 0, 5, 0, math.random(0, 288), 0 , 0,  spawnTeam) 
               outputChatBox("Bạn đã được respawn", source, 255, 0, 0) 
      end 
   end 
end 
addEventHandler("onResourceStart", root, respawn) 

Link to comment
function respawn(player) 
      local team = getPlayerTeam(player) 
      local health = getElementHealth(player) 
      if team then 
          if (getTeamName(team) == "Assasin") and health <0 then 
              spawnPlayer(source, 0, 0, 5, 0,  math.random(0, 288), 0, 0,  spawnTeam) 
              outputChatBox("Bạn đã được respawn", source, 255, 0, 0) 
              giveWeapon(source, 8, 1) 
              giveWeapon(source, 1, 1) 
       elseif (getTeamName(team) == "Gunner") then 
               spawnPlayer(source, 0, 0, 5, 0, math.random(0, 288), 0 , 0,  spawnTeam) 
               outputChatBox("Bạn đã được respawn", source, 255, 0, 0) 
      end 
   end 
end 
addEventHandler("onResourceStart", root, respawn) 

Link to comment

It's unnecessary to get player health.

Code

function respawn() 
    for _, player in ipairs(getElementsByType("player")) do 
     local team = getPlayerTeam(player) 
        if team then 
            if (getTeamName(team) == "Assasin") then 
              spawnPlayer(player, 0, 0, 5, 0,  math.random(0, 288), 0, 0,  spawnTeam) 
              giveWeapon(player, 8, 1) 
              giveWeapon(player, 1, 1) 
            elseif (getTeamName(team) == "Gunner") then 
              spawnPlayer(player, 0, 0, 5, 0, math.random(0, 288), 0 , 0,  spawnTeam) 
            end 
        end 
   end 
end 
addEventHandler("onResourceStart", resourceRoot, respawn) 
  
addEventHandler("onPlayerSpawn", root, function() 
    local team = getPlayerTeam(source) 
    if team then 
        if (getTeamName(team) == "Assasin") or (getTeamName(team) == "Gunner") then 
            outputChatBox("Bạn đã được respawn", source, 255, 0, 0) 
        end 
    end 
end) 

Link to comment
It's unnecessary to get player health.

Code

function respawn() 
    for _, player in ipairs(getElementsByType("player")) do 
     local team = getPlayerTeam(player) 
        if team then 
            if (getTeamName(team) == "Assasin") then 
              spawnPlayer(player, 0, 0, 5, 0,  math.random(0, 288), 0, 0,  spawnTeam) 
              giveWeapon(player, 8, 1) 
              giveWeapon(player, 1, 1) 
            elseif (getTeamName(team) == "Gunner") then 
              spawnPlayer(player, 0, 0, 5, 0, math.random(0, 288), 0 , 0,  spawnTeam) 
            end 
        end 
   end 
end 
addEventHandler("onResourceStart", resourceRoot, respawn) 
  
addEventHandler("onPlayerSpawn", root, function() 
    local team = getPlayerTeam(source) 
    if team then 
        if (getTeamName(team) == "Assasin") or (getTeamName(team) == "Gunner") then 
            outputChatBox("Bạn đã được respawn", source, 255, 0, 0) 
        end 
    end 
end) 

That's not what he want.

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...