Jump to content

Respawn


Recommended Posts

function spawnAfterDie()
setTimer(spawnAfterDie,1500,2,source)
coords = { 
	{ 2023.3244628906, 1007.233215332, 10.8203125 },
	{  2035.5523681641, 1027.8463134766, 10.8203125 },
	{ 2027.7517089844, 1917.6516113281, 12.337175369263 }
}	
local randomas = math.random(0,3)
spawnPlayer(source, coords[randomas][1], coords[randomas][2], coords[randomas][3])
fadeCamera(source, true)
setCameraTarget(source, source)
end

What wrong?

Link to comment

1. The timer can't be in the very same function it calls, or else it will create an endless loop.

2. You don't have an onPlayerWasted event handler. Also, the timer belongs in here.

3. The random function has a logical error. The first argument (0 in your script) should be 1, because lua tables start their index with a 1.

4. The timer has a 2 as repetition argument, that's probably unwanted..

Link to comment

setTimer(spawnAfterDie,1500,1,source)	
end
end
 
 
addEventHandler ( "onPlayerWasted", getRootElement(), rewardOnWasted, PlayerDeath ) --attach the rewardOnWasted function to the relevant event.
 
function spawnAfterDie()
coords = { 
	{ 2023.3244628906, 1007.233215332, 10.8203125 },
	{  2035.5523681641, 1027.8463134766, 10.8203125 },
	{ 2027.7517089844, 1917.6516113281, 12.337175369263 }
}	
local randomas = math.random(0,3)
spawnPlayer(source, coords[randomas][1], coords[randomas][2], coords[randomas][3])
fadeCamera(source, true)
setCameraTarget(source, source)
end

now? :x

Link to comment

I agree to what Gamesnert said.

For example line 2 and 3, there are two "end" parts, but no chunk to close.

Also have a look, to which handler function you attached the onPlayerWasted event.

The random function is still logically incorrect.

I would recommend you to read and learn some more about tables, events and their handlers and chunks.

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