Jump to content

Remove destroyed models of vehicles


Guest Gamer99

Recommended Posts

Hello all,

I recently edited a lua file in such a way which prevented vehicles to respawn, however as a result of this destroyed models still appear in position. What must I delete or add so that these destroyed models do not stay along for long if at all if possible once a vehicle has been destroyed?

Link to comment

I had the same problem, so I fixed it with this code:

function vehicleExplode () 
    --destroy wreck after 5 minutes 
    setTimer( destroyElement, 300000, 1, source) 
end 
  
addEventHandler ( "onVehicleExplode", getRootElement(), vehicleExplode )  

Of course, if you don't want the wreck at all, you can just call destroyElement(source) instead of the timer.

Link to comment

This is the one I use, it's only a slight variation of the one just posted and the one on the wiki. The differences are it respawns the car in its original position after the given time (6 seconds in this example) - or alternatively if it's a spawned vehicle that isn't part of the .map - it destroys it to stop the map getting cluttered up (also avoids 'andromeda hell' if you use a /createvehicle type command ;) )

  
function vehicleExplode () 
    -- if vehicle is part of the .map 
    if (getElementID ( source ) ~= nil and getElementID ( source ) ~= "" ) then  
            -- respawn it 
            setTimer ( respawnVehicle, 6000, 1, source )                             
    else   -- otherwise 
             -- destroy 
            setTimer ( destroyElement, 6000, 1, source )                   
    end 
end 
addEventHandler ( "onVehicleExplode", getRootElement(), vehicleExplode ) 

Link to comment
  • 1 month later...

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