Electro88 Posted August 14, 2017 Posted August 14, 2017 Hi all, I have a problem with team setspawn. It's not working. What I did wrong in this code ? function teamspawnset ( player, theCurrentAccount ) local x, y, z = getElementPosition(player ) local dim = getElementDimension( player ) local int = getElementInterior( player ) local color = getTeamColor( player) local gang = getPlayerTeam(player) local teamName = getTeamName ( gang ) account = getPlayerAccount (source) if (account) then setAccountData (account, "x, y, z", gang) elseif ( teamName == getTeamName ) then spawnPlayer (player, x, y, z ) outputChatBox ( "Succes!", source, 0, 255, 0, true ) else outputChatBox ( ":(", source, 255, 0, 0, true ) end end addCommandHandler ("setspawn", teamspawnset, player ) addEventHandler ( "onPlayerWasted", root, function() setTimer(teamspawnset, 5000, 1, source) end)
NeXuS™ Posted August 14, 2017 Posted August 14, 2017 What is this? You can type "setspawn", and your team will spawn whenever they die at the position you wrote the command in?
Hoffmann Posted August 14, 2017 Posted August 14, 2017 function teamspawnset ( player, cmd ) local x, y, z = getElementPosition( player ) local dim = getElementDimension( player ) local int = getElementInterior( player ) local gang = getPlayerTeam(player) local teamName = getTeamName ( gang ) for _, plr in pairs(getPlayersInTeam(gang)) do local account = getPlayerAccount(plr) if acc then setAccountData(account, "X", x) setAccountData(account, "Y", y) setAccountData(account, "Z", z) setAccountData(account, "dim", dim) setAccountData(account, "int", int) -- spawnPlayer(plr, x, y, z) UNCOMMENT THIS TO SPAWN EVERY PLAYER ON NEW COORDS end end outputChatBox ( "Succes!", source, 0, 255, 0, true ) end addCommandHandler ("setspawn", teamspawnset) function spawnTeammates(p) local acc = getPlayerAccount(p) if acc then local x, y, z = getAccountData(acc, "X"), getAccountData(acc, "Y"), getAccountData(acc, "Z") spawnPlayer(p, x, y, z) end end addEventHandler ( "onPlayerWasted", root, function() setTimer(spawnTeammates, 5000, 1, source) end) Try this code. Didn't test it. 1
Ahmed Ly Posted August 14, 2017 Posted August 14, 2017 5 minutes ago, NeverUnbeatable said: function teamspawnset ( player, cmd ) local x, y, z = getElementPosition( player ) local dim = getElementDimension( player ) local int = getElementInterior( player ) local gang = getPlayerTeam(player) local teamName = getTeamName ( gang ) for _, plr in pairs(getPlayersInTeam(gang)) do local account = getPlayerAccount(plr) if acc then setAccountData(account, "X", x) setAccountData(account, "Y", y) setAccountData(account, "Z", z) setAccountData(account, "dim", dim) setAccountData(account, "int", int) -- spawnPlayer(plr, x, y, z) UNCOMMENT THIS TO SPAWN EVERY PLAYER ON NEW COORDS end end outputChatBox ( "Succes!", source, 0, 255, 0, true ) end addCommandHandler ("setspawn", teamspawnset) function spawnTeammates(p) local acc = getPlayerAccount(p) if acc then local x, y, z = getAccountData(acc, "X"), getAccountData(acc, "Y"), getAccountData(acc, "Z") spawnPlayer(p, x, y, z) end end addEventHandler ( "onPlayerWasted", root, function() setTimer(spawnTeammates, 5000, 1, source) end) Try this code. Didn't test it. for _, plr in pairs(getPlayersInTeam(gang)) do local account = getPlayerAccount(plr) if account then 1
Hoffmann Posted August 14, 2017 Posted August 14, 2017 (edited) 12 minutes ago, Ahmed Ly said: for _, plr in pairs(getPlayersInTeam(gang)) do local account = getPlayerAccount(plr) if account then This code is actually terrible because it gets player's account and set it's data every iteration but anyway code is fixed, I think. Edited August 14, 2017 by NeverUnbeatable 1
Electro88 Posted August 14, 2017 Author Posted August 14, 2017 Code is working thanks and @Ahmed Ly 2
Hoffmann Posted August 14, 2017 Posted August 14, 2017 Just now, Electro88 said: Code is working thanks and @Ahmed Ly You're welcome.
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