Dzsipszi Posted November 8, 2012 Share Posted November 8, 2012 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
Castillo Posted November 8, 2012 Share Posted November 8, 2012 You want to turn off the engine when it get's damaged? Link to comment
Dzsipszi Posted November 8, 2012 Author Share Posted November 8, 2012 (edited) Yes, and let the car start up again if we enter into it. Because this is a good method in order for us to avoid non-rp drivers and dont let get away them Edited November 8, 2012 by Guest Link to comment
Castillo Posted November 8, 2012 Share Posted November 8, 2012 Use: setVehicleEngineState Link to comment
Dzsipszi Posted November 8, 2012 Author Share Posted November 8, 2012 function turnEngineOff ( onVehicleDamage ) if VehicleDamage setVehicleEngineState ( theVehicle, false ) end end addEventHandler ( "onVehicleDamage", getRootElement ( ), turnEngineOff ) maybe this useful? Link to comment
Castillo Posted November 8, 2012 Share Posted November 8, 2012 function turnEngineOff ( loss ) if ( loss > 0 ) then setVehicleEngineState ( source, false ) end end addEventHandler ( "onVehicleDamage", getRootElement ( ), turnEngineOff ) Link to comment
Dzsipszi Posted November 8, 2012 Author Share Posted November 8, 2012 Works fine! Thank you for help!! Link to comment
Dzsipszi Posted November 8, 2012 Author Share Posted November 8, 2012 (edited) 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 November 8, 2012 by Guest Link to comment
Castillo Posted November 8, 2012 Share Posted November 8, 2012 setTimer outputChatBox getPlayerName Link to comment
Dzsipszi Posted November 8, 2012 Author Share Posted November 8, 2012 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
TAPL Posted November 9, 2012 Share Posted November 9, 2012 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
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now