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
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
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?
Citizen.Wait(1500)
if IsPedInAnyVehicle(GetPlayerPed(-1), false) then
if (GetPedInVehicleSeat(veh, -1) == GetPlayerPed(-1)) then
vehicles[StateIndex][2] = not GetIsVehicleEngineRunning(veh)
if vehicles[StateIndex][2] then
exports[‘mythic_notify’]:DoHudText(‘inform’,‘Vehiculo encendido!’)
else
exports['mythic_notify']:DoHudText('inform','Vehiculo apagado!')
end
end
end
end)
AddEventHandler(‘EngineToggle:RPDamage’, function(State)
RPWorking = State
end)
if OnAtEnter then
Citizen.CreateThread(function()
while true do
Citizen.Wait(0)
if GetSeatPedIsTryingToEnter(GetPlayerPed(-1)) == -1 then
for i, vehicle in ipairs(vehicles) do
if vehicle[1] == GetVehiclePedIsTryingToEnter(GetPlayerPed(-1)) and not vehicle[2] then
Citizen.Wait(2000)
vehicle[2] = true
exports[‘mythic_notify’]:DoHudText(‘inform’,‘Vehiculo encendido!’)
end
end
end
end
end)
end
The third value means if it should start instantly or not.
And the easiest way to stop the shaking thing is just to add this somewhere, or implement it in the existing code.
Citizen.CreateThread(function()
while true do
if DoesEntityExist(GetVehiclePedIsTryingToEnter(PlayerPedId())) then --is player entering a vehicle
SetVehicleNeedsToBeHotwired(GetVehiclePedIsTryingToEnter(PlayerPedId()), false) -- disable native hotwire
--SetVehicleEngineOn(GetVehiclePedIsTryingToEnter(PlayerPedId()), false, false, true)
end
Citizen.Wait(300) -- requires minimum of 1. larger number saves some performance if necessary
end
end)
if im in a moving vehicle and turn the engine off, then turn it back on whilst its still moving i get launched through the windscreen, how can i stop this? it only really happens at like 50mph plus i think and when i dont have seatbelt on but it doesnt really make sense regardless
That kind of does make sense do that to a moving car in the gear in real life and see how it bucks, yes you wouldn’t be kicked out of the car but that’s the GTA rules for you.
And for those of you who don’t use esx, yo-yo-ma alerting, prefered the barebones version of this script, or want absolutely minimal interference, I’ve modified @Flatracer’s original script and trimmed it down…a loooot!
Changelog: Removed all other features, added logic to shut the engine off in certain scenarios (under 200 engine health OR vehicle not drivable) because there are some scenarios where the engine script kept trying to start your engine on a destroyed / undrivable car (sometimes causing a strange explosion noise).
Also, (at least for planes), 200 Engine health is the flatline where plane engines become undrivable…(The more ya know!)