[Release] [Free] [Standalone] Combined Engine Toggle & Leave Engine Running

Combined Engine Toggle and Leave Engine Running resource for FiveM.


Hi, this is my first sort-of script, so if there’s any suggestions to optimize the code or any features you’d like added, please feel free to let me know! :slight_smile:
It’s meant for more serious RP servers.

I wanted to find a resource for my server that would force the player to use their scroll wheel to toggle the engine on and off to use vehicles, as well as leaving the engine running if they got out of the car with it running. I searched all over the forums for such a script and couldn’t find it, so I made one myself.


The resource limits the player to the following:

  • Cannot start engine with ‘W’ key.
  • Disables auto-start when a player enters a vehicle or when vehicle is turned off.
  • Toggle engine state with Scrollwheel Up only (editable in client.lua).
  • Engine stays on after exiting the vehicle.

Due to how basic the script is, if you get into and out of the vehicle too fast the engine will turn off, I will look into this over the next few days to see what I can do about it.

Download the files from my GitHub here: https://github.com/aclfxdev/CET-LER


Hey. Good release. I took a quick glance at the code.
Some notes.

You can replace GetPlayerPed() with PlayerPedId() as it runs faster.

You can optimize the script by checking if the player is in a car, and if not then Wait(1000), or another number that’d work for the script. You could put your vehicle variable in that statement as well since you don’t have to loop through it when it’s not being used.

You can move local engineStatus outside of the loop.

You could do the function in this manner, and take use of the variables in the loop.
function toggleEngine(vehicle)

function toggleEngine(vehicle)
    if vehicle ~= nil and vehicle ~= 0 then
        local engineRunning = GetIsVehicleEngineRunning(vehicle)

        if engineRunning then
            SetVehicleEngineOn(vehicle, false, true, true)
            SetVehicleEngineOn(vehicle, true, true, true)

Thanks for your input! I’ll look into implementing those changes into the current code :slight_smile:


I hope you don’t mind, but I forked this and added the ability to keep the door open by holding the F key on vehicle exit (drivers side) by using:

Keep door open:
TaskLeaveVehicle(ped, vehicle, 256)

Close door:
TaskLeaveVehicle(ped, vehicle, 0)

What i did is a bit messy, but seems to work.

It still starts automatically after I get in the car, how can I solve this problem?

Can Someone help I don’t understend why my code dosen’t work the gui works fine but when I check the checkbox and leave the vehicle the car shutsdown like normaly

    while True do
        if engine == true then
            if GetVehiclePedIsIn(PlayerPedId(),false) ~= nil and GetVehiclePedIsIn(PlayerPedId(),false) ~=0 then
                local engineRunning = GetIsVehicleEngineRunning(GetVehiclePedIsIn(PlayerPedId(),false))

                if engineRunning then

            RageUI.Checkbox("Keep Engine on", "Always Keeps the engine on", engine, {}, function(Hovered, Active, Selected, Checked)
                if Selected then
                    engine = Checked