Jump to content

how to respawn object (that can explode).


GEN-Gavin

Recommended Posts

hi all am new at scripting lua but am lurning hard :D

i have one quastion,

how to respawn barrel and those missel and other object that can explode ore damage ore broken.

i know litelbit of respawning car and pickups.

but object that can be destroied i dont know i like to know how ore cant object respawn :?:

function respawnVehicle( vehicle ) 
    spawnVehicle ( vehicle, getElementData( vehicle, "posX" ), getElementData( vehicle, "posY" ), getElementData( vehicle, "posZ" ), getElementData( vehicle, "rotX" ), getElementData( vehicle, "rotY" ), getElementData( vehicle, "rotZ" ) ) 
end 
  
function onVehicleSpawn () 
    local x,y,z = getElementPosition (source) 
    setElementData (source,"posX",x) 
    setElementData (source,"posY",y) 
    setElementData (source,"posZ",z) 
end 
addEventHandler ("onVehicleExplode",getRootElement(),onVehicleSpawn) 
  
function onVehicleExplode () 
    setTimer( respawnVehicle, 5000, 1, source ) 
end 
addEventHandler("onVehicleExplode", getRootElement(), onVehicleExplode) 

this is a car respowner can i change some and make it to object respawner?

Link to comment
  • Moderators

Hi GEN-Gavin,

I see the events in server side, and I found onElementDestroy BUT ! this event is only triggered when an object was detroyed by destroyElement( the Element ) so he doesn't work.

Then I go to the Client Events and I found this:

OnClientExplosion

So you can use it but he's triggered only when an object explode ( like barrels )

Try this and tell me if it works

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