Jump to content

onVehicleDamage


Dzsipszi

Recommended Posts

I need some help please! The car has to stop if it has injury

function displayVehicleLoss(loss) 
    local thePlayer = getVehicleOccupant(source) 
    if(thePlayer) then -- Check there is a player in the vehicle 
        outputChatBox("Your vehicle just lost " .. tonumber(loss) .. " health.", thePlayer) -- Display the message 
    end 
end 
  
addEventHandler("onVehicleDamage", getRootElement(), displayVehicleLoss) 

And, let the car start up again if we enter into it...

Link to comment

Could it be possible to add delay to start engine while the player is in the car? Like someone bumped into a wall and he press W and he need to wait 10 seconds for start engine and the chance is 50% to start. And outboxchat to see everybody: Someone trying to start engine..., Someone has started the engine successful... or Someone failed to start engine... please? Because if you wrecked your car everytime you need to pull over and re-enter to your car... (nonrp)

    function turnEngineOff ( loss ) 
        if ( loss > 0 ) then 
            setVehicleEngineState ( source, false ) 
        end 
    end 
    addEventHandler ( "onVehicleDamage", getRootElement ( ), turnEngineOff ) 

Edited by Guest
Link to comment
function turnEngineOff ( loss ) 
    if ( loss > 0 ) then 
        setVehicleEngineState ( source, false ) 
        if bindKey (source, "i", "down", engineSwitch, source) then 
            setTimer ( engineSwitch ) 
        outputChatBox ( "Someone has started the engine successfuly..." ) 
        end, 10000, 1 ) 
    end 
end 
addEventHandler ( "onVehicleDamage", getRootElement ( ), turnEngineOff ) 

maybe this works?

Link to comment
function turnEngineOff ( loss ) 
    if ( loss > 0 ) then 
        setVehicleEngineState ( source, false ) 
        if bindKey (source, "i", "down", engineSwitch, source) then 
            setTimer ( engineSwitch ) 
        outputChatBox ( "Someone has started the engine successfuly..." ) 
        end, 10000, 1 ) 
    end 
end 
addEventHandler ( "onVehicleDamage", getRootElement ( ), turnEngineOff ) 

maybe this works?

No, source is the vehicle that got damaged and you are binding the key for the vehicle while the bindKey required player not vehicle. You need to use getVehicleController to get the driver of the vehicle.

Also the timer is wrong.

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