EngineToggle
FiveM Script - Vehicle Engine Toggle On/Off
I updated the old Script and added some cool things
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! - Hotwire Function in compatibility with VKC
Config
Config = {}
----------------------------------------------------------------
Config.Locale = 'de'
Config.VersionChecker = true
Config.getSharedObject = 'esx:getSharedObject'
----------------------------------------------------------------
-- Change 'false' to 'true' to toggle the engine automatically on when entering a vehicle
Config.OnAtEnter = false
----------------------------------------------------------------
Config.UseKey = true -- Set true if you want to use a Hotkey
Config.ToggleKey = 244 -- M (https://docs.fivem.net/docs/game-references/controls/)
Config.UseCommand = false -- Set true if you want to use a Command
Config.Commad = 'engine'
----------------------------------------------------------------
-- 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
----------------------------------------------------------------
-- !!! This function is clientside AND serverside !!!
-- Look for type == 'client' and type == 'server'
Config.Notification = function(src, type, xPlayer, message) -- xPlayer = ESX.GetPlayerFromId(src)
if type == 'client' then -- clientside
ESX.ShowNotification(message) -- replace this with your Notify // example: exports['okokNotify']:Alert('Crafting', message, 5000, 'info')
elseif type == 'server' then -- serverside
xPlayer.showNotification(message) -- replace this with your Notify // example: TriggerClientEvent('okokNotify:Alert', src, 'Crafting', message, 5000, 'info')
end
end
----------------------------------------------------------------
Config.progressBar = function(time, message)
exports['pogressBar']:drawBar(time, message)
end
----------------------------------------------------------------
Config.RemoveLockpickItem = true -- Set true if you like to remove item after failing lockpicking
Config.LockpickItem = 'lockpick' -- Set the itemname what you want to use
Config.startEngine = true -- Set true if you want to start the engine after successfull lockpicking
Config.Probability = {
lockpick = 66, -- default: 66%
alarm = 33, -- default: 33%
enableSearchKey = true, -- Set false if you dont want this
searchKey = 66 -- default: 66%
}
Config.LockpickKey = {
enable = false, -- Set to true if you want to use a Hotkey
key = 38 -- default: E // Set the Hotkey
}
Config.ProgessBar = {
enable = true, -- Set true if you want to show a progressbar
time = 8 -- In seconds // Time how long does it takes
}
Config.Animation = {
InsideOutsideAnimation = true, -- Set to false if you want same Animation for inside and outside
generalAnimation = 'WORLD_HUMAN_WELDING',
insideVehicle = { -- Animation inside Vehicle
dict = 'anim@amb@clubhouse@tutorial@bkr_tut_ig3@',
anim = 'machinic_loop_mechandplayer'
},
outsideVehicle = { -- Animation outside Vehicle
dict = 'anim@amb@clubhouse@tutorial@bkr_tut_ig3@',
anim = 'machinic_loop_mechandplayer'
}
}
Requirements
- Standalone
- ESX Framework only for
Hotwire Function
Optional
- VehicleKeyChain ([Release] Vehicle Key Chain)
- ProgessBar ([Release] Pogress Bar (Progress Bar, standalone, smooth animation))
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('EngineToggle:RPDamage', true)
end
if healthEngineCurrent <= cfg.engineSafeGuard+1 and cfg.limpMode == false then
SetVehicleUndriveable(vehicle,true)
TriggerEvent('EngineToggle:RPDamage', false)
end
My other Scripts
Paid
- [ESX] MSK Armor - Multiple Armor Vests
- [ESX] MSK Bankingsystem with NativeUI [V2]
- [ESX] MSK Crafting - with NativeUI
- [ESX] MSK Handcuffs - Realistic Handcuffs
- [ESX] MSK SaveCoordMenu
- [ESX] MSK Shopsystem - NativeUI & Database Feature
- [ESX/QBCore] MSK Simcard - Change your phonenumber - #53 by Musiker15
- [ESX] MSK WeaponAmmo | Clips, Components & Tints
Free
- [ESX] Backpack Plugin | Chezza Inventory
- [ESX] MSK Deathcounter - integrated in myMultichar
- [Re-Release] EngineToggle
- GitHub - Musiker15/msk_givevehicle: Give Vehicles with Command or Item and Delete Vehicles with Command
- GitHub - MSK-Scripts/msk_rgbHeadlights: Changeable Vehicle Headlights with an Item
- [ESX/QBCore] MSK SecretBlips - Show and delete Blips with an item
- GitHub - MSK-Scripts/msk_weaponammoitems: Weapon Ammunition as Items
Changelogs
Update v3.4
- Changed a lot of things
- Added new Configs for Notifications and ProgressBar
- Fixed getting a TempKey if Hotwire a Vehicle failed
- Fixed Player shaking inside car without engine running
Update v3.1.4
- Fixed an issue were the vehicle is nil after lockpicking
Update v3.1.3
Added Probability for searchKey function
Update v3.1.2
- Fixed Notification Bug after failed lockpicking
Update v3.1.1
- Bugfix for this Error:
SCRIPT ERROR: @VehicleKeyChain/server/server.lua:363: Parameter "playerId" must be a number!
fixed by Kiminaze
Update v3.1
- Added Hotwire Function in compatibility with VehicleKeyChain
Update v3.0.1
- Bugfix for last Update v3.0
Update v3.0
- Added Support for latest VehicleKeyChain by Kiminaze