[Re-Release] EngineToggle

EngineToggle

FiveM Script - Vehicle Engine Toggle On/Off

Download: GitHub - Musiker15/EngineToggle: FiveM Script - Vehicle EngineToggle | Keeps the engine running if you leave the vehicle without turning the engine off

I updated the old Script and added some cool things :slight_smile:

Old Topic: [Release] Engine ON/OFF Toggle

Description

  • The engine keeps running if you leave the vehicle without turning the engine off.
  • You can set that the engine starts automatically when entering a vehicle.
  • You can choose if you use a Hotkey or a Command.
  • You can choose between 3 diffrent Notifications.
  • If you set Config.VehicleKeyChain to true then only the Owner of the Vehicle or someone with a Key can start the Engine!

Config

Config = {}
Config.Locale = 'en'

-- Change 'false' to 'true' to toggle the engine automatically on when entering a vehicle
Config.OnAtEnter = false

Config.UseKey = true
    Config.ToggleKey = 244 -- M (https://docs.fivem.net/docs/game-references/controls/)
Config.UseCommand = true
    Config.Commad = 'engine' -- If Config.UseKey = false then you can use the command instead

-- If both false then Default ESX Notification is active!
Config.Notifications = false -- https://forum.cfx.re/t/release-standalone-notification-script/1464244
Config.OkokNotify = false -- https://okok.tebex.io/package/4724993

-- Vehicle Key System - set true then only the Owner of the Vehicle or someone with a Key can start the Engine
Config.VehicleKeyChain = false -- https://kiminazes-script-gems.tebex.io/package/4524211

Requirements

  • ESX Framework only for ESX.ShowNotification

Optional

VehicleKeyChain

Make sure to add the following in every Script that spawns a Vehicle

-- Give a Key to the Player
SetVehicleNumberPlateText(vehicle, 'PLATE_TEXT')
exports["kimi_callbacks"]:Trigger("VKC:createNewKey", 'PLATE_TEXT', 1, true)
-- Remove the Key from the Player
exports["kimi_callbacks"]:Trigger("VKC:removeKey", 'PLATE_TEXT', 1)

RealisticVehicleDamage

If you use RealisticVehicleDamage, then replace following Code in client.lua on Line 333 in RealisticVehicleDamage:

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

Changelogs

Update v2.9
  • Updated VersionChecker
  • Updated Readme.md for VehicleKeyChain Support
Update v2.8.1

Bugfix for v2.8

  • Changed playerPed to PlayerPedId()
Update v2.8
  • Faster Callback
  • Fixed Notification if Player don’t have a Key and is outside of a vehicle and pressing ToggleKey
Update v2.7
  • Added locale files
  • You can change the language in config.lua
  • New Design for Version Chcecker
Update v2.6.5
  • Added Server Console Print if Config.VehicleKeyChain = true to see if this Script is started or stopped.
7 Likes

Very Nice Release, thank you very much!

1 Like

can u make it for qbcore aswell

Very Nice :+1:

Should work with qbcore. Please try it out :slight_smile:

ok will do and let u know soon

this script needs changing abit maybe put the m button to G instead would be better

You can do that by yourself in config.lua :slight_smile:

yh did and it made my server go wired i mean loads of wired letters on screen

Synced between players?

Update v2.6.5

  • Added Server Console Print if Config.VehicleKeyChain = true to see if this Script is started or stopped.

Download: Releases · Musiker15/EngineToggle · GitHub

1 Like

Yes it is synced between players

1 Like

Are you sure it’s synced? Because I just ran this script on my server, testing with someone in the UK (I’m in Australia), and the engine status does not sync unless we both turn the car on or off ourselves.
Running OneSync Infinity, latest (as of 5 days ago) artefact, admittedly very old framework. Configs are as default, except for keybind change. Version 2.6.5. Script is running fine, other than the lack of syncing between players.

Also, might I suggest using a locale file so server devs don’t need to manually translate the… German, is it? Up to you if you want to do this though. :slight_smile:

Update v2.7

  • Added locale files
  • You can change the language in config.lua
  • New Design for Version Checker

Update v2.8

  • Faster Callback
  • Fixed Notification if Player don’t have a Key and is outside of a vehicle and pressing ToggleKey

Update v2.8.1

Bugfix for v2.8

  • Changed playerPed to PlayerPedId()

Hey, zuerst mal geiles Script!

Benutze es jetzt schon ungefähr eine Woche, läuft alles Super.
Ich habe zum einen die esx_dmvschool und den Mechaniker Job wo der Spieler keine Schlüssel für das Fahrzeug bekommt.
Wie kann ich es so konfigurieren, dass der Spieler trotz “VehicleKeyChain = true” das Fahrzeug an und ausschalten kann?

function StartDriveTest(type)
    ESX.Game.SpawnVehicle(Config.VehicleModels[type], Config.Zones.VehicleSpawnPoint.Pos, Config.Zones.VehicleSpawnPoint.Pos.h, function(vehicle)
        CurrentTest       = 'drive'
        CurrentTestType   = type
        CurrentCheckPoint = 0
        LastCheckPoint    = -1
        CurrentZoneType   = 'residence'
        DriveErrors       = 0
        IsAboveSpeedLimit = false
        CurrentVehicle    = vehicle
        LastVehicleHealth = GetEntityHealth(vehicle)

        local playerPed   = PlayerPedId()
        TaskWarpPedIntoVehicle(playerPed, vehicle, -1)
        SetVehicleFuelLevel(vehicle, 100.0)
        DecorSetFloat(vehicle, "_FUEL_LEVEL", GetVehicleFuelLevel(vehicle))
        SetVehicleNumberPlateText(vehicle, 'SCHOOL')

        exports["kimi_callbacks"]:Trigger("VKC:createNewKey", 'SCHOOL', 1, true)
        --print('VKC: Schlüssel wurde hinzugefügt')
    end)

    TriggerServerEvent('esx_dmvschool:pay', Config.Prices[type])
end

function StopDriveTest(success)
    if success then
        TriggerServerEvent('esx_dmvschool:addLicense', CurrentTestType)
        ESX.ShowNotification(_U('passed_test'))

        exports["kimi_callbacks"]:Trigger("VKC:removeKey", 'SCHOOL', 1)
        --print('VKC: Schlüssel wurde entfernt')
    else
        ESX.ShowNotification(_U('failed_test'))

        exports["kimi_callbacks"]:Trigger("VKC:removeKey", 'SCHOOL', 1)
        --print('VKC: Schlüssel wurde entfernt')
    end

    CurrentTest     = nil
    CurrentTestType = nil
end

Update v2.9

  • Updated VersionChecker
  • Updated Readme.md for VehicleKeyChain Support


i have a mistake