maky55 Posted March 25, 2015 Share Posted March 25, 2015 Hey guys! So, my friend is helping me learn scripting. And I've also been following the wiki. I have made this script with the help of the wiki and my friend, and he told me to figure it out for myself. So, I wanted to make a script so you can re spawn when you die. I did it and it was quite easy, but you re spawned straight away. I asked my friend if I could use a timer or something so you have to wait for 5 seconds until you re spawn. Here is what I came up with so far: local spawnX, spawnY, spawnZ = 133.78814697266, -35.417057037354, 1.578125 function joinHandler() spawnPlayer(source, spawnX, spawnY, spawnZ) fadeCamera(source, true) setCameraTarget(source, source) outputChatBox("Welcome to the test server!", source) end addEventHandler("onPlayerJoin", getRootElement(), joinHandler) function deathTimer() setTimer(deathHandler,5000,1) end local spawnX, spawnY, spawnZ = 133.78814697266, -35.417057037354, 1.578125 function deathHandler() spawnPlayer(source, spawnX, spawnY, spawnZ) fadeCamera(source, true) setCameraTarget(source, source) outputChatBox("And... BAM, you're back!", source) end addEventHandler("onPlayerWasted", getRootElement(), deathTimer) The problem is with this, the timer works and it waits for 5 seconds, but in staid of respawning, only the text shows and your camera is left floating in the sky. I made a video for it here: https://www.youtube.com/watch?v=sxzJVwTWHCo&feature=youtu.be Any help with this would me much appreciated! Thanks Tiger. Link to comment
xXMADEXx Posted March 25, 2015 Share Posted March 25, 2015 Be sure to check errors in debugscript before posting. (/debugscript 3) This is caused, because "source" isn't defined in the deathHandler function. Try this: local spawnX, spawnY, spawnZ = 133.78814697266, -35.417057037354, 1.578125 function joinHandler() spawnPlayer(source, spawnX, spawnY, spawnZ) fadeCamera(source, true) setCameraTarget(source, source) outputChatBox("Welcome to the test server!", source) end addEventHandler("onPlayerJoin", getRootElement(), joinHandler) function deathTimer() setTimer(deathHandler,5000,1, source) end local spawnX, spawnY, spawnZ = 133.78814697266, -35.417057037354, 1.578125 function deathHandler( source ) spawnPlayer(source, spawnX, spawnY, spawnZ) fadeCamera(source, true) setCameraTarget(source, source) outputChatBox("And... BAM, you're back!", source) end addEventHandler("onPlayerWasted", getRootElement(), deathTimer) Link to comment
maky55 Posted March 25, 2015 Author Share Posted March 25, 2015 Be sure to check errors in debugscript before posting. (/debugscript 3)This is caused, because "source" isn't defined in the deathHandler function. Try this: local spawnX, spawnY, spawnZ = 133.78814697266, -35.417057037354, 1.578125 function joinHandler() spawnPlayer(source, spawnX, spawnY, spawnZ) fadeCamera(source, true) setCameraTarget(source, source) outputChatBox("Welcome to the test server!", source) end addEventHandler("onPlayerJoin", getRootElement(), joinHandler) function deathTimer() setTimer(deathHandler,5000,1, source) end local spawnX, spawnY, spawnZ = 133.78814697266, -35.417057037354, 1.578125 function deathHandler( source ) spawnPlayer(source, spawnX, spawnY, spawnZ) fadeCamera(source, true) setCameraTarget(source, source) outputChatBox("And... BAM, you're back!", source) end addEventHandler("onPlayerWasted", getRootElement(), deathTimer) Thank you! Sorry I'm new and didn't think of using debug. After I had posted this, I had fixed it another way: function deathTimer() player=source setTimer(deathHandler,5000,1,player) --https://wiki.multitheftauto.com/wiki/SetTimer end But the way you put it seems alot simpler! Thank you for your help. Ill be sure to debug next time Link to comment
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