MysteriousNewbie Posted April 9, 2010 Posted April 9, 2010 hello , how to make respawn when player die in wiki i didn't found about that
Dark Dragon Posted April 9, 2010 Posted April 9, 2010 you can use a timer (setTimer) when a player dies (onPlayerWasted) and then simply spawn them (spawnPlayer)
MysteriousNewbie Posted April 9, 2010 Author Posted April 9, 2010 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?
dzek (varez) Posted April 9, 2010 Posted April 9, 2010 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?
MaddDogg Posted April 9, 2010 Posted April 9, 2010 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..
MysteriousNewbie Posted April 9, 2010 Author Posted April 9, 2010 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?
Gamesnert Posted April 9, 2010 Posted April 9, 2010 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.
MaddDogg Posted April 9, 2010 Posted April 9, 2010 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.
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now