Jump to content

spawnPlayer


Lloyd Logan

Recommended Posts

How will thesurvivor be selected, i mean how you will make the script select thesurvivor?

What about if thesurvivor dead before everyone?

-- Server Side --

-- thesurvivor should be defined somewhere. 
addEventHandler("onPlayerWasted", root, 
function() 
    local alivePlayers = getAlivePlayers() 
    if source == thesurvivor then 
        -- thesurvivor dead, do something.. 
    elseif #alivePlayers == 1 and alivePlayers[1] == thesurvivor then 
        -- everyone dead, except thesurvivor. 
        for i, player in ipairs(getElementsByType("player")) do -- get all players. 
            spawnPlayer(player, x, y, z) -- spawn all players. 
            setCameraTarget(player) -- make the camera follow him. 
        end 
    end 
end) 

Link to comment
How will thesurvivor be selected, i mean how you will make the script select thesurvivor?

What about if thesurvivor dead before everyone?

-- Server Side --

-- thesurvivor should be defined somewhere. 
addEventHandler("onPlayerWasted", root, 
function() 
    local alivePlayers = getAlivePlayers() 
    if source == thesurvivor then 
        -- thesurvivor dead, do something.. 
    elseif #alivePlayers == 1 and alivePlayers[1] == thesurvivor then 
        -- everyone dead, except thesurvivor. 
        for i, player in ipairs(getElementsByType("player")) do -- get all players. 
            spawnPlayer(player, x, y, z) -- spawn all players. 
            setCameraTarget(player) -- make the camera follow him. 
        end 
    end 
end) 

So is this a valid script or just an "along the lines" example?

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...