[Release] Engine ON/OFF Toggle

Does anyone know how i could implement mythic_notify into this?

image

1 Like

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

Could you tell me how can I make this engine open only by the owner? thank you!

Change this

SetVehicleEngineOn(vehicle[1], vehicle[2], true, false)

to this

SetVehicleEngineOn(vehicle[1], vehicle[2], false, false)

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)
3 Likes

Thanks, this is the start sound solution!
Only the shaking part is not working for my, how is this at your end ?

Edit: it works only first time en then you got the key animation.

1 Like

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.

How do we fix this for hellicopters? Should I comment/delete off line 31?

Nevermind. Commenting/removing line 31 “SetHeliBladesFullSpeed(vehicle[1])” fixes this for helicopters.

I’m having this problem: when i get in the car, it starts, i go with it a little bit and it turns off and turns on randomly

Where is it , the download ?

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!

This is for the command version ONLY, but enjoy:
client.lua (2.9 KB)
fxmanifest.lua (220 Bytes)

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!)

1 Like

maybe anyone can explain why character is shaking while stearing wheel turn left or right when vehicle engine is off?