Jump to content

Spawn


xeon17

Recommended Posts

Hello , how can i spawn player when he die on 3 place's. When he die it should spawn him on some of the spawnpoints from the table.

local mySpawnTable = { 
{331.06286621094, 1855.9083251953, 7.828125},  
{216.45199584961, 1822.6893310547, 6.4140625},  
{211.66558837891, 1810.6231689453, 21.8671875}  
} 
  
  
function makePlayerSpawn (player) 
local spawnPoint = mySpawnTable[math.random(#mySpawnTable)] -- random spawnpoint 
spawnPlayer(player,spawnPoint[1],spawnPoint[2],spawnPoint[3]) 
end 
  

But how ?

Link to comment
  
local spawnLocations = { 
{331.06286621094,1855.9083251953,7.828125}, 
{216.45199584961,1822.6893310547,6.4140625}, 
{211.66558837891,1810.6231689453,21.8671875} 
} 
  
local respawnPlayer = function() 
    local chosenSpawnLocation = math.random(1,#spawnLocations) 
    spawnPlayer(source,spawnLocations[chosenSpawnLocation][1],spawnLocations[chosenSpawnLocation][2],spawnLocations[chosenSpawnLocation][3]) 
end 
addEventHandler("onPedWasted",root,respawnPlayer) 
  

Link to comment

https://wiki.multitheftauto.com/wiki/OnPedWasted is only triggered when a ped die, I think you want https://wiki.multitheftauto.com/wiki/OnPlayerWasted

  
local spawnLocations = { 
{331.06286621094,1855.9083251953,7.828125}, 
{216.45199584961,1822.6893310547,6.4140625}, 
{211.66558837891,1810.6231689453,21.8671875} 
} 
  
local respawnPlayer = function() 
    local chosenSpawnLocation = math.random(1,#spawnLocations) 
    spawnPlayer(source,spawnLocations[chosenSpawnLocation][1],spawnLocations[chosenSpawnLocation][2],spawnLocations[chosenSpawnLocation][3]) 
end 
addEventHandler("onPlayerWasted",root,respawnPlayer) 

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