Jump to content

[question]stop car engine on car crash?


cokacola

Recommended Posts

okay thanks :)

didn't notice there was a vehicle damage function

but the car engine state works as i have /engine to start and stop the engine(found it here, but understand how it works )

thanks!

Edit:

Okay, I tried it, and it doesn't do anything...here is my code, and i smashed into many a wall with the car :P

  
function stopEngine() 
    setVehicleEngineState2(source, false) 
end 
addEventHandler("onVehicleDamage",getRootElement(),stopEngine) 
  

say...just does nothing :/

EDIT:

okay it works now, but its really easy to break a car.. just tap a pole and the engine stops, is it possible to make it so you'd have to hit something hard for it to stop?

Link to comment

There is that parameter for triggered function in onVehicleDamage which is "loss". It represents how much damage your car got in this "hit", so just check if the "loss" is larger then some value and you're done. Read the wiki more, it's your best friend, just after google.

Link to comment
  • 2 weeks later...
okay thanks :)

didn't notice there was a vehicle damage function

but the car engine state works as i have /engine to start and stop the engine(found it here, but understand how it works )

thanks!

Edit:

Okay, I tried it, and it doesn't do anything...here is my code, and i smashed into many a wall with the car :P

  
function stopEngine() 
    setVehicleEngineState2(source, false) 
end 
addEventHandler("onVehicleDamage",getRootElement(),stopEngine) 
  

say...just does nothing :/

EDIT:

okay it works now, but its really easy to break a car.. just tap a pole and the engine stops, is it possible to make it so you'd have to hit something hard for it to stop?

Look this:

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 make a new onVehicleDamage with set how many HP it has to stop. Like 200.

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