[help]engine off/on script

Does anyone have a script where you can do /engine on /engine off or /engine to do both


SetVehicleEngineOn(entity, true/fale)

would this work


AddEventHandler( ‘chatMessage’, function( source, n, msg ]

msg = string.lower( msg )

-- Check to see if a client typed in /dv
if ( msg == "/engine" ) then 

    -- Cancel the chat message event (stop the server from posting the message)

    -- Trigger the client event 
    TriggerClientEvent( 'Engine', source )

`-- Register a network event
RegisterNetEvent( ‘Engine’ )

AddEventHandler( ‘Engine’, function()
local ped = GetPlayerPed( -1 )

    if ( IsPedSittingInAnyVehicle( ped ) ) then 
        local vehicle = GetVehiclePedIsIn( ped, false )

        if ( GetPedInVehicleSeat( vehicle, -1 ) == ped ) then 
            ShowNotification( "EngineOn/Off." )
            SetEntityAsMissionEntity( vehicle, true, true )
            SetVehicleEngineOn(entity, true/fale)( vehicle )
            ShowNotification( "You must be in the driver's seat!" )
            ShowNotification( "You must be in a vehicle to turn the engine off/on" )

end )’

I was giving you an example, you obviously have to change the arrays, but in your case it would look like this

SetVehicleEngineOn(vehicle, false)

Has anyone gotten this script to work?

Yes, I did.

EngineToggle.rar (932 Bytes)

VirusTotal Scan

1 Like

It works! Thank you Flatracer!

anyway to set it up to where the engine will stay on when you get out of the car?

Do any of you know how to make this script work with the new fivem update? Is that before I was great, but since the update of the new server does not work well, I explain I enter the game write / engine the car goes off and automatically the character starts.

Before it was off, you know if something needs to be changed? Thank you

1 Like

did you find the solution?