Jump to content

Respawning vehicles to a position.


GamingTim

Recommended Posts

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? :/

Link to comment

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) 

Link to comment
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.

Link to comment
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.

Link to comment
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 
  

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