Script - Fivem Car Key
-- Remove key from player (when vehicle is sold/destroyed) RegisterNetEvent('carkeys:removeKey') AddEventHandler('carkeys:removeKey', function(plate) local src = source local xPlayer = Framework.GetPlayerFromId(src) local keyItem = string.format('%s_%s', Config.KeyItem, plate) xPlayer.removeInventoryItem(keyItem, 1) end)
-- Notification style Config.Notify = function(msg, type) -- type: 'info', 'error', 'success' -- Change this to your framework's notification if Config.Framework == 'esx' then ESX.ShowNotification(msg) elseif Config.Framework == 'qb' then QBCore.Functions.Notify(msg, type) else print(msg) end end fivem car key script
-- Toggle engine on/off (only if you have key) Citizen.CreateThread(function() while true do Citizen.Wait(0) if IsControlJustPressed(0, 303) then -- U key (change in config) local ped = PlayerPedId() if IsPedInAnyVehicle(ped, false) then local vehicle = GetVehiclePedIsIn(ped, false) local plate = GetVehicleNumberPlateText(vehicle) lib.callback.await('carkeys:hasKey', false, plate) if hasKey then engineOn = not engineOn SetVehicleEngineOn(vehicle, engineOn, false, true) if engineOn then Config.Notify('Engine started', 'success') else Config.Notify('Engine turned off', 'info') end else Config.Notify('You don't have the key!', 'error') end end end end end) -- Remove key from player (when vehicle is
-- Engine start keybind (optional) Config.EngineKeybind = 'U' type) -- type: 'info'
-- Check if player has key for specific plate lib.callback.register('carkeys:hasKey', function(source, plate) local xPlayer = Framework.GetPlayerFromId(source) local keyItem = string.format('%s_%s', Config.KeyItem, plate) local count = xPlayer.getInventoryItem(keyItem).count return count > 0 end) local Framework = nil local currentVehicle = nil local engineOn = false local vehicleLocked = true local ownedVehicles = {} -- store plate -> hasKey -- Load framework Citizen.CreateThread(function() if Config.Framework == 'esx' then TriggerEvent('esx:getSharedObject', function(obj) Framework = obj end) elseif Config.Framework == 'qb' then Framework = exports['qb-core']:GetCoreObject() end end)
client_scripts { 'config.lua', 'client.lua' }



5 Comments
Chris
11 August 2022 at 21:55Do you have HOW TO…for bullet holes or shell holes ie tank turrent etc…
ScaleDracula
12 August 2022 at 02:29Not yet, mate. Maybe some day. In the meantime you can check these videos by uncle Nightshift:
https://www.youtube.com/watch?v=8I3lY0zQPbg
https://www.youtube.com/watch?v=N9tkYqRLyRY
Dario Risso
13 September 2022 at 16:58Hi there! Nice job! As I understand, you leave the tape glued on the glass piece, right? Then glue the glass part with…which face out the vehicle?
ScaleDracula
13 September 2022 at 20:46Yes. The taped side should probably face the inside of the vehicle. So it’s not that visible.
Dario Risso
13 September 2022 at 21:31Great, thanks!!