Jump to content

Blow up vehicles in water


Tails

Recommended Posts

Posted

Hi there,

function explodeVehiclesInWater ( ) 
    local vehicles = getElementsByType ( "vehicle" ) 
    for _, vehicle in ipairs ( vehicles ) do 
        if isElementInWater( vehicle ) then 
        setTimer ( function() 
        blowVehicle( vehicle, true ) 
    end, 10000, 1 ) 
        end 
    end 
end 
addEventHandler ( "onResourceStart", root, explodeVehiclesInWater ) 

If you read the script then you know I want. I need this script to explode vehicles when they go under water.

Ofcourse it's not working so if anyone could take a look and tell me what's wrong with it I would appreciate it a lot!

Thanks in advance

Discord: its.tails

Posted

You want to check every 10 seconds for vehicles in wanter and blow them up?

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted

No, this is a script for freeroam, so if you someone drives their vehicle into the water I need it to explode so my respawn script can respawn it.

Discord: its.tails

Posted

Yes, but your script is currently setting a timer for every vehicle that is in water to blow it up, only when the resource start.

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted
setTimer ( 
    function ( ) 
        for _, vehicle in ipairs ( getElementsByType ( "vehicle" ) ) do 
            if isElementInWater ( vehicle ) then 
                blowVehicle ( vehicle, true ) 
            end 
        end 
    end 
    , 10000, 0 
) 

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted

Thank you , I appreciate it! Although, I found it won't explode sometimes when the player isn't in the vehicle.

Discord: its.tails

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