Jump to content

Respawn


Recommended Posts

Posted

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?

Posted

before you will start making anything read one more time the basics of Lua..

setTimer should be outside the function to work..

but then your "source" will not be set

and why you set your timer to do its job TWO times?

Posted

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

Posted

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

Posted

I wonder, do you actually understand what you just wrote? I bet you don't.

Find some Lua tutorials on the internet. There are plenty around. Then try to find your own mistakes. Trial and error isn't getting anyone anywhere.

Posted

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.

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