GamingTim Posted April 26, 2014 Posted April 26, 2014 local vehicle = createVehicle ( 470, -490.39999389648, -486.60000610352, 25.60000038147 ) function respawnExplodedVehicle() toggleVehicleRespawn( vehicle, true ) setVehicleRespawnDelay( vehicle, 5000 ) end addEventHandler("onVehicleExplode", getRootElement(), respawnExplodedVehicle) Now what did i do wrong this time?
Saml1er Posted April 26, 2014 Posted April 26, 2014 You must check if the source is the specified vehicle. local myVeh = createVehicle ( 470, -490.39999389648, -486.60000610352, 25.60000038147 ) function respawnExplodedVehicle() if source == myVeh then -- make sure its the vehicle that you want toggle respawn toggleVehicleRespawn( myVeh, true ) setVehicleRespawnDelay( myVeh, 5000 ) end end addEventHandler("onVehicleExplode", getRootElement(), respawnExplodedVehicle)
GamingTim Posted April 26, 2014 Author Posted April 26, 2014 You must check if the source is the specified vehicle. local myVeh = createVehicle ( 470, -490.39999389648, -486.60000610352, 25.60000038147 ) function respawnExplodedVehicle() if source == myVeh then -- make sure its the vehicle that you want toggle respawn toggleVehicleRespawn( myVeh, true ) setVehicleRespawnDelay( myVeh, 5000 ) end end addEventHandler("onVehicleExplode", getRootElement(), respawnExplodedVehicle) Tried but still i got the same problem, i still cant see the vehicle respawning.
Saml1er Posted April 27, 2014 Posted April 27, 2014 You must check if the source is the specified vehicle. local myVeh = createVehicle ( 470, -490.39999389648, -486.60000610352, 25.60000038147 ) function respawnExplodedVehicle() if source == myVeh then -- make sure its the vehicle that you want toggle respawn toggleVehicleRespawn( myVeh, true ) setVehicleRespawnDelay( myVeh, 5000 ) end end addEventHandler("onVehicleExplode", getRootElement(), respawnExplodedVehicle) Tried but still i got the same problem, i still cant see the vehicle respawning. Its because when the vehicle is destroyed (exploded) then it doesn't exist you must set respawn to true before the vehicle is destroyed.
GamingTim Posted April 27, 2014 Author Posted April 27, 2014 It's already been set to true am I right? toggleVehicleRespawn( myVeh, true) Still, the vehicle won't respawn. I don't get it.
Saml1er Posted April 27, 2014 Posted April 27, 2014 It's already been set to true am I right? toggleVehicleRespawn( myVeh, true) Still, the vehicle won't respawn. I don't get it. I meant toggleVehicleRespawn does not work with onVehicleExplode if the vehicle that you want to respawn is the vehicle that exploded. For example, can a dead person eat food or drink water? The answer is no. So when the exploded is myVeh then server memory reads your code like this: function respawnExplodedVehicle() toggleVehicleRespawn( myVeh, true ) -- myVeh is not defined setVehicleRespawnDelay( myVeh, 5000 ) -- myVeh is not defined end addEventHandler("onVehicleExplode", getRootElement(), respawnExplodedVehicle
LonelyRoad Posted April 27, 2014 Posted April 27, 2014 With the Event onVehicleExplode the Source is the vehicle that exploded. Use respawnVehicle (See Also: setTimer) on the source to respawn the vehicle back to where-ever you did createVehicle (See Also: setVehicleRespawnPosition)
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