Physical Keys (p_vehiclekeys)
Kartik scripts support p_vehiclekeys. When it is running, vehicle keys are given and taken as a physical car_key item in ox_inventory, with the plate saved in the item's metadata (metadata.plate).
p_vehiclekeys does not ship the two events our scripts call, so you add them once to p_vehiclekeys and every Kartik script uses them.
📦 Scripts that use it
- Garages V2
- Dealership
- Mechanic
- Police Job
- Properties & Housing
- Gangs V2
- Evidence
- Laptop and Boosting
- Ambulance Job
- DOJ Job
Nothing has to be changed in these scripts. They detect p_vehiclekeys when they start.
⚙️ Setup
1. Add the key events
Open p_vehiclekeys/server.lua and paste this at the bottom:
local function trim(str)
return type(str) == 'string' and str:match('^%s*(.-)%s*$') or ''
end
RegisterNetEvent('p_vehiclekeys:givekeys', function(plate)
local src = source
plate = trim(plate)
if plate == '' then return end
if exports.ox_inventory:GetItemCount(src, 'car_key', { plate = plate }) > 0 then return end
exports.ox_inventory:AddItem(src, 'car_key', 1, { plate = plate })
end)
RegisterNetEvent('p_vehiclekeys:removekeys', function(plate)
local src = source
plate = trim(plate)
if plate == '' then return end
local count = exports.ox_inventory:GetItemCount(src, 'car_key', { plate = plate })
if count < 1 then return end
exports.ox_inventory:RemoveItem(src, 'car_key', count, { plate = plate })
end)2. Check the item
Make sure the car_key item from p_vehiclekeys is in ox_inventory/data/items.lua.
3. Start order
Start ox_inventory and p_vehiclekeys before any Kartik script in server.cfg:
ensure ox_inventory
ensure p_vehiclekeys
ensure kartik-garages
ensure kartik-dealership
# ... other kartik scriptsRestart the server once after adding the events.
🧾 How keys behave
- A player never gets two keys for the same plate.
- Removing keys takes every key that player holds for that plate.
- Only spaces at the start and end of a plate are removed, the same way p_vehiclekeys reads plates. A plate like
AB 12 CDkeeps its middle space, so the key matches the car.
❓ Troubleshooting
- Check that the two events from step 1 are at the bottom of
p_vehiclekeys/server.luaand that you restarted the server. - Check that
p_vehiclekeysstarts before the Kartik script. If it starts later, the script falls back to another keys script or gives no keys. - Make sure no other keys script (for example
qbx_vehiclekeys) is also running, or that one may be used instead.
You probably pasted an older version of the events that removed every space from the plate. Plates with a space in the middle (for example AB 12 CD) then get a key for AB12CD. Replace the events with the ones in step 1, and give players new keys for those vehicles.
Make sure you use the events from step 1. They skip giving a key when the player already holds one for that plate.