Jump to content

Blow Vehicle on Water


ksTakor

Recommended Posts

I am trying to make an script that when some types of vehicle fall in the water after 30 seconds it explode.

How can i make the function blowVehicle only explode the vehicles id's that i want?

And how to set a timer to only explode after 30 seconds when fall in water?

Searching in the forum I find this script:

function blow() 
        for _, vehicle in ipairs ( getElementsByType ( "vehicle" ) ) do 
            if isElementInWater ( vehicle ) then 
                blowVehicle ( vehicle, true ) 
                outputChatBox(getPlayerName(source).." #0099FFToco el agua y exploto!",getRootElement(), 255, 255, 255, true) 
            end 
        end 
end 
  
  
addEventHandler ( "onClientPlayerWasted",getRootElement(), blow) 

Can you help me modificate this?

Link to comment

Like this?

function blow() 
        for _, vehicle in ipairs ( getElementsByType ( "vehicle" ) ) do 
            if isElementInWater ( vehicle ) then 
            local id = getElementModel ( vehicle ) 
                if id == 470 or id == 422 or id == 437 or id == 433 or id == 497 or id == 487 or id == 468 then 
                    setTimer (blowater, 30000, 1) 
                else 
            end 
        end 
end 
  
  
addEventHandler ( "onVehicleDrown",getRootElement(), blow) 
  
function blowater () 
    blowVehicle (vehicle, true) 
end 

Link to comment

Try this ;

server ;

VehiclesID = { [470]=true,[422]=true,[437]=true,[433]=true,[497]=true,[478]=true,[468]=true } 
  
addEventHandler("onResourceStart",resourceRoot, 
function ( ) 
    setTimer( 
        function ( ) 
            for _,v in pairs ( getElementsByType("player") ) do 
            local vehicle = getPedOccupiedVehicle(v) 
            if not vehicle then return end 
            if isElementInWater ( vehicle ) then 
            if (  VehiclesID[getElementModel(vehicle)] ) then 
            setTimer( 
                function( ) 
                blowVehicle( vehicle ) 
                 end,3000,1) 
                end 
            end 
        end 
    end,250,0,v) 
end 
) 
            
    

Link to comment

It has other way?

Because its a dayz gamemode and I don't want my player dead, I only want blow the vehicle to respawn.

The event isElementInWater bug in server sided, can I make this script client side?

Because if the player is killed he loses his itens.

Link to comment

Try this ;

VehiclesID = { [470]=true,[422]=true,[437]=true,[433]=true,[497]=true,[478]=true,[468]=true } 
  
addEventHandler("onClientResourceStart",resourceRoot, 
function ( ) 
    setTimer( 
        function ( ) 
            local vehicle = getPedOccupiedVehicle(localPlayer) 
            if not vehicle then return end 
            if isElementInWater ( vehicle ) then 
            if (  VehiclesID[getElementModel(vehicle)] ) then 
            setTimer( 
                function( ) 
                blowVehicle( vehicle ) 
                 end,1000,1) 
              end 
        end 
    end,250,0) 
end 
) 
            
    

Link to comment

If Will Try this ;

client ;

VehiclesID = { [470]=true,[422]=true,[437]=true,[433]=true,[497]=true,[478]=true,[468]=true } 
  
local allow = nil 
addEventHandler("onClientResourceStart",resourceRoot, 
function ( ) 
    setTimer( 
        function ( ) 
            if allow then return end         
            local vehicle = getPedOccupiedVehicle(localPlayer) 
            if not vehicle then return end       
            if isElementInWater ( vehicle ) then 
            if (  VehiclesID[getElementModel(vehicle)] ) then 
                setTimer( 
                function( ) 
                    allow = true 
                    triggerServerEvent("Data",localPlayer,vehicle) 
                end,1000,1) 
            end 
        end 
    end,250,0) 
end 
) 
  
  
addEvent("allow",true) 
addEventHandler("allow",root, 
    function () 
        allow = nil 
    end 
) 

server ;

addEvent("Data",true) 
addEventHandler("Data",root, 
    function ( vehicle ) 
        if not isPedInVehicle(source) then return end 
        blowVehicle( vehicle ) 
        if isObjectInACLGroup ("user.".. getAccountName ( getPlayerAccount ( source ) ), aclGetGroup ( "Admin" ) ) then 
            outputChatBox("* The Player ; "..getPlayerName(source).." Vehicle Has Been Blowed!",getRootElement(),0,255,255,true) 
        end 
        triggerClientEvent(source,"allow",source)        
    end 
) 

And tell me what happened .

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