KainDepZai Posted April 4, 2015 Share 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) Link to comment
ALw7sH Posted April 4, 2015 Share Posted April 4, 2015 onClientResourceStart this is a client side event and you are using server side functions Link to comment
KainDepZai Posted April 4, 2015 Author Share Posted April 4, 2015 then i have to change to Client Side ?? Link to comment
Dimos7 Posted April 4, 2015 Share 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 Link to comment
KainDepZai Posted April 4, 2015 Author Share Posted April 4, 2015 it not working pls help me Link to comment
KainDepZai Posted April 4, 2015 Author Share Posted April 4, 2015 Client side like this : addEventHandler("onClientResourceStart", root, respawn) or triggles server ??? Link to comment
KainDepZai Posted April 4, 2015 Author Share Posted April 4, 2015 can you show me problem with line 6 ?? Link to comment
FlyingSpoon Posted April 4, 2015 Share 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 Link to comment
Dimos7 Posted April 4, 2015 Share 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 Link to comment
KainDepZai Posted April 4, 2015 Author Share Posted April 4, 2015 still not working ( Link to comment
FlyingSpoon Posted April 4, 2015 Share 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. Link to comment
FlyingSpoon Posted April 4, 2015 Share Posted April 4, 2015 @KainDepZai - Did you try my version Client-Side? Link to comment
Dimos7 Posted April 4, 2015 Share Posted April 4, 2015 use /devuscript 3 and write here what error says Link to comment
FlyingSpoon Posted April 4, 2015 Share 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) Link to comment
Dimos7 Posted April 4, 2015 Share 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 Link to comment
KainDepZai Posted April 4, 2015 Author Share Posted April 4, 2015 i try it but still not working Link to comment
KainDepZai Posted April 4, 2015 Author Share Posted April 4, 2015 @Ray please help me ( Link to comment
Dimos7 Posted April 4, 2015 Share 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) Link to comment
KainDepZai Posted April 4, 2015 Author Share Posted April 4, 2015 still not working ( Link to comment
Dimos7 Posted April 4, 2015 Share Posted April 4, 2015 /debugscript 3 test it and write the error please Link to comment
KainDepZai Posted April 4, 2015 Author Share Posted April 4, 2015 http://i.imgur.com/WQrnSuB.png Link to comment
Dimos7 Posted April 4, 2015 Share 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) Link to comment
KainDepZai Posted April 4, 2015 Author Share Posted April 4, 2015 i will check it at 10AM i have to sleep Link to comment
Enargy, Posted April 4, 2015 Share 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) Link to comment
Mr.unpredictable. Posted April 4, 2015 Share 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. Link to comment
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