msk_enginetoggle icon indicating copy to clipboard operation
msk_enginetoggle copied to clipboard

[ESX/QBCore] Vehicle EngineToggle On/Off

EngineToggle

FiveM Script - Vehicle Engine Toggle On/Off

GitHub release (latest by date)

Forum: https://forum.cfx.re/t/re-release-enginetoggle/4793840

Discord Support: https://discord.gg/5hHSBRHvJE

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!
  • Hotwire Function in compatibility with VKC

Requirements

  • Standalone
  • ESX Framework only for Hotwire Function

Optional

  • VehicleKeyChain (https://forum.cfx.re/t/release-vehicle-key-chain/3319563)
  • ProgessBar (https://forum.cfx.re/t/release-pogress-bar-progress-bar-standalone-smooth-animation/838951)

VehicleKeyChain

If you want to add a permanent key:

-- clientside --
local plate = GetVehicleNumberPlateText(vehicle)
TriggerServerEvent('VKC:setKey', true, plate, 1) -- Give a Key to the Player
TriggerServerEvent('VKC:setKey', false, plate, 1) -- Remove the Key from the Player

-- or this one

-- clientside --
-- Give a Key to the Player
local plate = 'ABC 123'
SetVehicleNumberPlateText(vehicle, plate) -- Only if you don't use AdvancedParking
exports["AdvancedParking"]:UpdatePlate(vehicle, plate) -- Only if you use AdvancedParking
TriggerServerEvent('VKC:setKey', true, plate, 1)
-- Remove the Key from the Player
TriggerServerEvent('VKC:setKey', false, plate, 1)

-- serverside --
RegisterServerEvent('VKC:setKey')
AddEventHandler('VKC:setKey', function(set, plate, count)
    if set then -- Add Key
        exports["VehicleKeyChain"]:AddKey(source, plate, count)
    else -- Remove Key
        exports["VehicleKeyChain"]:RemoveKey(source, plate, count)
    end
end)

If you only want a temporary key that will be deleted after restart use this:

-- clientside --
TriggerServerEvent("VKC:giveTempKey", true, "PLATE") -- Add Temp Key
TriggerServerEvent("VKC:giveTempKey", false, "PLATE") -- Remove Temp Key

-- serverside --
RegisterNetEvent("VKC:giveTempKey")
AddEventHandler("VKC:giveTempKey", function(set, plate)
    if set then -- Add Temp Key
        exports["VehicleKeyChain"]:AddTempKey(source, plate)
    else -- Remove Temp Key
        exports["VehicleKeyChain"]:RemoveTempKey(source, plate)
    end
end)

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('msk_enginetoggle:RPDamage', true)
end

if healthEngineCurrent <= cfg.engineSafeGuard+1 and cfg.limpMode == false then
    SetVehicleUndriveable(vehicle,true)
    TriggerEvent('msk_enginetoggle:RPDamage', false)
end

QB-Vehiclefailure

IF you use qb-vehiclefailure, then replace the following Code in client.lua on Line 530 in qb-vehiclefailure:

if healthEngineCurrent > cfg.engineSafeGuard+1 then
    SetVehicleUndriveable(vehicle, false)
    TriggerEvent('msk_enginetoggle:RPDamage', true)
end

if healthEngineCurrent <= cfg.engineSafeGuard+1 and cfg.limpMode == false then
    local vehpos = GetEntityCoords(vehicle)
    StartParticleFxLoopedAtCoord("ent_ray_heli_aprtmnt_l_fire", vehpos.x, vehpos.y, vehpos.z-0.7, 0.0, 0.0, 0.0, 1.0, false, false, false, false)
    SetVehicleUndriveable(vehicle, true)
    TriggerEvent('msk_enginetoggle:RPDamage', false)
end

My other Scripts

PAID

FREE

License

GNU General Public License v3.0