KainDepZai Posted April 4, 2015 Posted April 4, 2015 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)
ALw7sH Posted April 4, 2015 Posted April 4, 2015 onClientResourceStart this is a client side event and you are using server side functions
Dimos7 Posted April 4, 2015 Posted April 4, 2015 (edited) spawnplayer is only server side not client put onResourceStart to make it server also on spawnPlayer needplayer x,y,z and interior and dimention and skin Edited April 4, 2015 by Guest
KainDepZai Posted April 4, 2015 Author Posted April 4, 2015 Client side like this : addEventHandler("onClientResourceStart", root, respawn) or triggles server ???
FlyingSpoon Posted April 4, 2015 Posted April 4, 2015 (edited) 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 April 4, 2015 by Guest
Dimos7 Posted April 4, 2015 Posted April 4, 2015 (edited) 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 April 4, 2015 by Guest
FlyingSpoon Posted April 4, 2015 Posted April 4, 2015 Dimos7, for some reason I tested yours outputs a few errors, Also you forgot this -- 0 ,0 spawnTeam) Comma! And it outputs errors in console.
FlyingSpoon Posted April 4, 2015 Posted April 4, 2015 @KainDepZai - Did you try my version Client-Side?
FlyingSpoon Posted April 4, 2015 Posted April 4, 2015 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)
Dimos7 Posted April 4, 2015 Posted April 4, 2015 (edited) @raysmta you can't use giveWeapon and spawnPlayer to cleint side its only for server side that is server side i make Edited April 4, 2015 by Guest
Dimos7 Posted April 4, 2015 Posted April 4, 2015 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)
Dimos7 Posted April 4, 2015 Posted April 4, 2015 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)
Enargy, Posted April 4, 2015 Posted April 4, 2015 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)
Mr.unpredictable. Posted April 4, 2015 Posted April 4, 2015 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.
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now