[Release] Engine ON/OFF Toggle

Nice Job!

The issue im running into is that Police vehicles wonā€™t toggle the engine. Other vehicles turn off, but any type of police vehicle will not allow for the engine to be toggle on/off? Any thoughts or suggestions?

Iā€™ve tried adding this script to my server but I just get this, http://prntscr.com/ndqcnk

Did you edit any part of the server.lua?

No I did not

The driver starts shaking before starting the engine, any solution?

To fix this in RealisticVehicleFailure:
In client/main.lua

On line 334 ( SetVehicleUndriveable(vehicle,false) ) 
add this code in new line after:
 TriggerEvent('EngineToggle:RPDamage', true)

On line 338 ( SetVehicleUndriveable(vehicle,true) ) 
add this code in new line after:
 TriggerEvent('EngineToggle:RPDamage', false)

:wink:

4 Likes

hello , this script is so good and i really like it , but when you spawn in cars , engines are offā€¦
(a lot of ppl dont know how they can turn engine on (new players))

You mean here right ?

if healthEngineCurrent > cfg.engineSafeGuard+1 then
				SetVehicleUndriveable(vehicle,false)
			end

			if healthEngineCurrent <= cfg.engineSafeGuard+1 and cfg.limpMode == false then
				SetVehicleUndriveable(vehicle,true)
			end

Cuz i found 2 other locations with: SetVehicleUndriveable

1 Like

For me function correctly as explained above

How do modified the the start key only work if its your vehicle otherwise it you cant turn on the engine like carlock?

It actually works. Just in the new version of this script you have to look around lines 660 +

Another problem: cars are drive-able UNDER the water. How to fix this?
With EngineToggle stopped problem is gone, but once the resource is running, I can drive every singe car under the water ā€¦well, at least until my lung capacity air is gone and Iā€™m dead under the water with my carā€™s engine still running :wink:

This script is great!

Only problem Iā€™m having is that, if players try to open a locked car, the car starts its engine even though they didnā€™t enter.

I want to keep ā€œauto-startā€ on because I think itā€™s helpful for new players, however I do not want cars to start just because someone attempted to open a locked door.

Does anyone have a good fix for this aside from disabling the auto-start?

For Fix conflicts with Realistic Vehicle Failure Systems:

Use this on Realistic Vehicule Failure (line 331):

			if healthEngineCurrent > cfg.engineSafeGuard+1 then
				SetVehicleUndriveable(vehicle,false)
				TriggerEvent('EngineToggle:RPDamage', true)
			end

			if healthEngineCurrent <= cfg.engineSafeGuard+1 and cfg.limpMode == false then
				SetVehicleUndriveable(vehicle,true)
				TriggerEvent('EngineToggle:RPDamage', false)
			end
1 Like

dont work for me, maybe i did something wrong, could you be more specific where to put this?

On client.lua, my lines are 333 and 338

You need to add only:

  • Line 333: TriggerEvent(ā€˜EngineToggle:RPDamageā€™, true)
  • Line 338: TriggerEvent(ā€˜EngineToggle:RPDamageā€™, false)
			if healthPetrolTankCurrent == 1000 then healthPetrolTankLast = 1000.0 end
			healthPetrolTankNew = healthPetrolTankCurrent
			healthPetrolTankDelta = healthPetrolTankLast-healthPetrolTankCurrent
			healthPetrolTankDeltaScaled = healthPetrolTankDelta * cfg.damageFactorPetrolTank * cfg.classDamageMultiplier[vehicleClass]

			if healthEngineCurrent > cfg.engineSafeGuard+1 then
				SetVehicleUndriveable(vehicle,false)
				TriggerEvent('EngineToggle:RPDamage', true)
			end

			if healthEngineCurrent <= cfg.engineSafeGuard+1 and cfg.limpMode == false then
				SetVehicleUndriveable(vehicle,true)
				TriggerEvent('EngineToggle:RPDamage', false)
			end

			-- If ped spawned a new vehicle while in a vehicle or teleported from one vehicle to another, handle as if we just entered the car
			if vehicle ~= lastVehicle then
				pedInSameVehicleLast = false
			end
1 Like

thanks, now itā€™s working! my lines was over ~450+

dont you have the last version?

Great work!
Few problems. Driver is shaking while engine is off and there is no sound when starting engine. Is there a way to fix it? Maybe to make engine dead to prevent player from shaking?