GR1M Docs

Carkeys

Qbox vehicle keys and vehicle controls: keys as items, hotwiring and glovebox minigames, and a built-in vehicle control menu.

v0.3.0Needs qbx_core, ox_lib, oxmysql, ox_inventory

#Stack

#Install

  1. Import sql/gr1m_carkeys.sql (the resource also creates the table on start).
  2. Add ensure GR1M_Carkeys after the dependencies.
  3. Stop any other vehicle key or vehicle control script (for example vehicles_keys, qb-vehiclekeys, cd_vehiclecontrol).
  4. Optional: apply the small qbx_core / qbx_adminmenu patches in install/qbox_integration.md so /car and admin-menu spawns give keys.
  5. Add the lockpick and advancedlockpick items to ox_inventory if your server does not have them (names set in config.lua).

#Commands

#Vehicle access flow

#Key types

#Compatibility

Legacy event names such as vehicles_keys:selfGiveVehicleKeys, vehicles_keys:selfRemoveKeys, and vehiclekeys:client:SetOwner are registered. The manifest declares provide 'vehicles_keys' for dependency resolution.

txAdmin vehicle-menu spawns receive temporary keys through a short-lived, server-validated correlation between txAdmin's authorized spawn log and driver-seat events. The authorized txAdmin FIX action also grants the administrator a temporary key for their current vehicle when Config.TxAdmin.grantOnFix is enabled. Tuning and disable controls are under Config.TxAdmin; transfer and verification notes are in docs/LIVE_SERVER_INTEGRATION.md.

The existing cd_vehiclecontrol:OpenUI event and /vehcontrol command open the same built-in NUI. The manifest declares provide 'cd_vehiclecontrol' for dependency resolution. Full controls include doors, hood/trunk, windows, seat switching, engine/locks, headlights, interior light, indicators/hazards, neon, extras, liveries, and seat-shuffle prevention. GR1M_Carkeys owns indicator state through Config.VehicleControl.stateKey; its NUI, keybinds, export, state-bag handler, and hotwire reactions all use that same state. Remote fob commands are re-authorized by the server for the selected networked vehicle on every press.

The compact K-menu Access page uses icon controls for the red/green engine state, low/high beams, LD/RD/BLD/BRD doors, hood, trunk, close-all, and an adjacent four-window grid. Signals remain on their own page. The synchronized windowMask is authoritative for windows Carkeys rolled down, allowing individual buttons to raise them even when GTA temporarily reports the lowered glass as non-intact; genuinely broken windows remain unavailable and are not repaired.

Passengers can use cabin controls. Engine and lock actions still follow the key/hotwire rules. Extras and liveries default to stopped, keyed emergency-service vehicles and can be tuned in Config.VehicleControl.

Config.VehicleControl.lights.headlightMultiplier controls runtime headlight brightness (1.0 is GTA stock; the default here is 1.25). Indicator and hazard emissive/corona brightness on addon vehicles remains controlled by each vehicle's carcols.meta.

Config.VehicleControl.indicators.fallbackGlow adds a synchronized amber point-light fallback for dim or incomplete indicator models. It prefers the vehicle's native indicator bones, then uses the matching headlight or brake/tail-light bones before falling back to model-relative corners. boneOffset moves bone-anchored lights slightly outward to the visible lens surface. With synchronizeNativeBlink enabled, Carkeys drives the native indicator and fallback light from the same clock so their flashes stay in phase.

Vehicle lockpicking accepts both the normal and advanced usable-item events and consumes the same item that opened the attempt. It uses the built-in warm, mechanical mouse-raking NUI with one primary instruction: hold E to apply tension, sweep the mouse left and right across the cylinder to search the pins, and move vertically to control rake height. The current binding pin seats automatically at its shear point while loose pins spring back. Seated pins remain up only while E is held; releasing it before the lock opens drops them. Sustained oversetting builds pick strain. A/D and W/S remain as an unlisted keyboard fallback. Vehicle class controls pin count, tolerance, timer, rake step, and pick durability through Config.Lockpick; an advanced lockpick receives the configured time, tolerance, and durability bonuses. Hard and elite hotwire profiles receive ten additional seconds compared with their original timers.

The glovebox search remains a separate minigame inside the same NUI. A completed search is still required before the server authorizes any hotwire attempt. The server decides whether a glovebox key exists before the search opens. When the UI actually contains a key and the player finds it, that exact search grants a temporary key without a second random roll.

Config.Hotwire.variant selects the hotwire game: trace for the vehicle-reactive circuit tracer, harness for drag-to-terminal wires, sequence for the signal-memory sequencer, or random to choose from Config.Hotwire.variants. The default is trace.

The trace game uses independent lead/terminal colors, connector glyphs, stripe codes, partial tags, a tested-pair matrix, and an event log. Wrong pairs can operate harmless vehicle circuits (lights, horn, hazards, cabin light, windows, hood/trunk, and radio) or dangerous fictional faults (alarm and electrical sparks). Effects never start the engine, unlock the vehicle, or grant keys.

When a compatible vehicle radio resource is running, the radio reaction uses its triggerCircuitPulse client export to play a short KXIM pulse through the managed world-audio path without replacing the vehicle's normal saved radio state. The native GTA radio is used only as a fallback.

Trace tuning lives under Config.Hotwire.trace:

Police notification lives under Config.Hotwire.police. The default kartik-mdt backend calls its VehicleTheft export when hotwiring starts (notifyAfterMistakes = 0). Set the threshold to 1 or 2 to alert after that many wrong tests, use custom to receive the server event GR1M_Carkeys:policeAlert, or use none to disable dispatch. Alerts are limited to once per attempt and one per plate every 120 seconds by default.

FiveM cannot make exports.vehicles_keys:* identical to exports.GR1M_Carkeys:* solely through event aliases. Integrations that hard-code the old resource name must be migrated or handled by a separate alias resource.

Install: qbox integration

GR1M_Carkeys registers the common key events and exports itself, but Qbox's admin vehicle spawners call key resources by name. These small patches to other resources make /car and admin-menu spawns hand out keys. They are optional but recommended.

Recheck and reapply this document after replacing or updating qbx_core or qbx_adminmenu, because those updates can overwrite the integration.

#Files outside GR1M_Carkeys

FileUsed byRequired behavior
[framework]/qbx_core/config/server.lua/carPrefer the GR1M_Carkeys:GiveKey server export.
[framework]/[qbx]/qbx_adminmenu/server/main.luaAdmin-menu vehicle spawnGrant the spawning admin a temporary key through GR1M_Carkeys.
[standalone]/vehiclehandler/modules/handler.lua/fixPreserve a running/hotwired ignition and refresh vehiclehandler's in-seat damage snapshot after repair.
[system]/cd_vehiclecontrol/configs/client_customise_me.luaLegacy overlap guardIf the old resource is accidentally active during migration, ask GR1M_Carkeys:CanUseVehicle before rejecting an engine start.

txAdmin does not require an external file patch. Its integration lives inside GR1M_Carkeys and therefore travels with the resource.

#Patch 1: qbx_core /car

Open [framework]/qbx_core/config/server.lua and find giveVehicleKeys = function(src, plate, vehicle).

After the existing plate validation and before local keys = exports.vehicles_keys, add:

if GetResourceState('GR1M_Carkeys') == 'started' then
    return exports.GR1M_Carkeys:GiveKey(src, plate, 'temporary')
end

The resulting section should follow this structure:

giveVehicleKeys = function(src, plate, vehicle)
    if not plate and vehicle and DoesEntityExist(vehicle) then
        plate = GetVehicleNumberPlateText(vehicle)
        plate = plate and string.gsub(plate, '^%s*(.-)%s*$', '%1') or nil
    end
    if not plate then return false end

    if GetResourceState('GR1M_Carkeys') == 'started' then
        return exports.GR1M_Carkeys:GiveKey(src, plate, 'temporary')
    end

    local keys = exports.vehicles_keys
    -- Keep the existing legacy fallback below this line.
end,

Do not remove the existing vehicles_keys fallback unless every old integration has been migrated.

#Patch 2: qbx_adminmenu vehicle spawning

Open [framework]/[qbx]/qbx_adminmenu/server/main.lua and find the qbx_admin:server:spawnVehicle callback. Replace its old vehicles_keys-only grant block with:

local plate = qbx.getVehiclePlate(vehicle)
if plate and GetResourceState('GR1M_Carkeys') == 'started' then
    exports.GR1M_Carkeys:GiveKey(source, plate, 'temporary')
elseif plate and GetResourceState('vehicles_keys') == 'started' then
    local keys = exports.vehicles_keys
    if type(keys.giveVehicleKeysToPlayerId) == 'function' then
        keys:giveVehicleKeysToPlayerId(source, plate, 'temporary')
    elseif type(keys.GiveVehicleKeysToPlayerId) == 'function' then
        keys:GiveVehicleKeysToPlayerId(source, plate, 'temporary')
    end
end

The admin menu also emits qb-vehiclekeys:client:AddKeys. GR1M_Carkeys/client/main.lua handles that event as a compatibility fallback, so make sure the entire Carkeys resource is copied rather than only its server files.

#txAdmin vehicle spawning

Verified against the official citizenfx/txAdmin source at commit 8a9a41410000fd92a527fe11bae2b8eeeb8b10e0. Its vehicle menu reports an authorized spawn through the server event txsv:logger:menuEvent, then seats the player through the client event txcl:seatInVehicle. Carkeys correlates those signals for the short period configured by Config.TxAdmin.grantWindowMs.

The server grants a temporary key for a txAdmin spawn only when all of these checks pass:

This integration is version-sensitive because the event names belong to txAdmin's bundled menu resource. After updating FXServer artifacts or txAdmin, repeat the txAdmin verification below. Disable it with Config.TxAdmin.enabled = false if those events change.

txAdmin FIX reports the separately authorized action vehicleRepair. When Config.TxAdmin.grantOnFix is enabled, Carkeys grants a temporary key for the administrator's current vehicle directly from that server-authorized action. The server still verifies the player and nearby vehicle; no client-supplied plate is trusted.

#Resource order

Place the resource after its dependencies:

ensure qbx_core
ensure ox_lib
ensure oxmysql
ensure ox_inventory
ensure GR1M_Carkeys

Do not run the old vehicles_keys, GR1M_hotwire, or cd_vehiclecontrol resources beside GR1M_Carkeys unless a deliberate compatibility test requires one of them.

If cd_vehiclecontrol is temporarily left running, its CanStartVehicleWithJaksamKeys helper must prefer the real GR1M_Carkeys resource and its CanUseVehicle client export. Otherwise an external engine start such as /fix can be rejected even though the vehicle has the replicated gr1m_hotwired state.

The vehiclehandler /fix implementation must also refresh its active handler data after SetVehicleFixed. The handler thread remains active while the player stays in the driver seat; retaining the pre-repair engine, body, and speed snapshot can make the repaired state disagree with the hotwire engine keeper until the player exits and re-enters.

#Restart requirement

Use a full server restart after applying the live-server patches. The /car integration is part of the qbx_core server configuration and will not reload from restart GR1M_Carkeys alone. Avoid restarting qbx_core by itself during an active session.

#Verification

After the restart, test with an opted-in administrator:

  1. Run /car sultan and confirm the engine starts without search or hotwire prompts.
  2. Run /managekeys and confirm the spawned plate appears as a temporary key.
  3. Spawn a different vehicle from the Qbox admin menu and repeat both checks.
  4. Restart only GR1M_Carkeys, spawn from the admin menu again, and confirm its QB compatibility event still grants the key.
  5. Spawn a vehicle from the txAdmin in-game menu and confirm it starts immediately and appears in /managekeys as temporary.
  6. Enter an unkeyed vehicle, use txAdmin FIX, and confirm the fixed vehicle is added to /managekeys as temporary.

If either spawn path requires hotwiring, first confirm GetResourceState('GR1M_Carkeys') is started, then compare both external files with the snippets above.