Jump to content

deleting all 0 life cars, or cars on the water


HeavyMetal

Recommended Posts

i use a resource to save all cars on my server, and it saves destroyed cars too, what is a problem,so i almost fixed this problem by using a script that delete the vehicle when it explode, but now i noticed that if a car fall on the water

it will reach 0 life and get destroyed without exploding, so it will not get deleted by the server and will get saved.

anyone knows a way to delete all 0 life cars or something triggered by the vehicle falling on the water to delete itself?

i couldnt find anything on resources or in the forums about this, so im posting.

thanks

Link to comment
setTimer( 
    function( ) 
        for _, aVehicle in next, getElementsByType 'vehicle' do 
            if (isElementInWater( aVehicle )) or (getElementHealth(aVehicle) == 0)) then 
                destroyElement(aVehicle) 
            end 
        end 
    end, 5000, 0 
) 

Link to comment

Try this:

  
setTimer( function() 
    for _,vehicle in ipairs(getElementsByType("vehicle")) do 
        if isElementInWater(vehicle) and getElementHealth(vehicle) == 0 then 
            destroyElement(vehicle) 
        end 
    end 
end, 1300, 0 
) 
  

Link to comment

i found a problem, dont know if i caused it but, i removed the getElementHealth part to delete all cars in the water even if it is not destroyed, and i found out that when i start the resource it is deleting all cars in the server. what is wrong?

setTimer( function() 
    for _,vehicle in ipairs(getElementsByType("vehicle")) do 
        if isElementInWater(vehicle) then 
            destroyElement(vehicle) 
        end 
    end 
end, 1300, 0 
) 

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