Jump to content

Setspawn code for teams


Electro88

Recommended Posts

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)

 

 

 

Link to comment
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.

  • Thanks 1
Link to comment
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

 

  • Thanks 1
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...