Kartik Scripts

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 scripts

Restart 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 CD keeps its middle space, so the key matches the car.

❓ Troubleshooting

On this page