Carkeys
Qbox vehicle keys and vehicle controls: keys as items, hotwiring and glovebox minigames, and a built-in vehicle control menu.
#Stack
- qbx_core
- ox_lib
- oxmysql
- ox_inventory
#Install
- Import
sql/gr1m_carkeys.sql(the resource also creates the table on start). - Add
ensure GR1M_Carkeysafter the dependencies. - Stop any other vehicle key or vehicle control script (for example
vehicles_keys,qb-vehiclekeys,cd_vehiclecontrol). - Optional: apply the small qbx_core / qbx_adminmenu patches in
install/qbox_integration.mdso/carand admin-menu spawns give keys. - Add the
lockpickandadvancedlockpickitems to ox_inventory if your server does not have them (names set inconfig.lua).
#Commands
/carkeysopens the keyfob for the closest keyed vehicle (default key:L, rebindable in FiveM key bindings). The fob has separate lock/unlock, remote engine, trunk, locate-flash, lend-to-nearby, and panic-alarm buttons./vehcontrolopens the compact bottom-anchored control NUI while inside a vehicle (default key:K). The keyfob remains a separate right-side interface onL.- Left Arrow toggles the left indicator while driving.
- Right Arrow toggles the right indicator while driving.
- Up Arrow toggles the hazard lights while driving.
/managekeysshows the current character's keys./givekey [server id]shares temporary keys for the closest keyed vehicle. Omit the id to lend to the closest nearby player. The keyfob LEND button does the same for the fob's selected vehicle.
#Vehicle access flow
- Press
Ein the driver's seat of an unkeyed vehicle to search it for keys. - If the search does not find keys, press
Eagain to hotwire it. - Hotwiring before the vehicle has been searched is rejected by the server.
- A hotwired vehicle keeps its ignition bypass active while driven, so its engine cannot be switched off while
Config.Hotwire.keepEngineRunningis enabled. - Drivers see a persistent
HOTWIRED // IGNITION BYPASSplate indicator whileConfig.Hotwire.showDriverIndicatoris enabled.
#Key types
owned: derived fromplayer_vehicles; never manually removed.permanent: persistent database grant.shared: persistent database grant that the holder can remove.temporary: memory-only grant, removed on disconnect/resource restart.
#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:
faultPolicy:dangerous_only(default),all_wrong, ornone.effectPersistence:keep_harmless(default) orrestore_all.harmlessEffects,dangerousEffects, and per-difficultydangerousChanceenable and tune reactions.
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.
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
| File | Used by | Required behavior |
|---|---|---|
[framework]/qbx_core/config/server.lua | /car | Prefer the GR1M_Carkeys:GiveKey server export. |
[framework]/[qbx]/qbx_adminmenu/server/main.lua | Admin-menu vehicle spawn | Grant the spawning admin a temporary key through GR1M_Carkeys. |
[standalone]/vehiclehandler/modules/handler.lua | /fix | Preserve a running/hotwired ignition and refresh vehiclehandler's in-seat damage snapshot after repair. |
[system]/cd_vehiclecontrol/configs/client_customise_me.lua | Legacy overlap guard | If 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:
- txAdmin reported an allowed
spawnVehicleaction; - the claim arrives before the authorization window expires;
- the network entity exists and is near the player;
- the player is in its driver seat;
- the spawned model matches the model authorized by txAdmin.
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:
- Run
/car sultanand confirm the engine starts without search or hotwire prompts. - Run
/managekeysand confirm the spawned plate appears as a temporary key. - Spawn a different vehicle from the Qbox admin menu and repeat both checks.
- Restart only
GR1M_Carkeys, spawn from the admin menu again, and confirm its QB compatibility event still grants the key. - Spawn a vehicle from the txAdmin in-game menu and confirm it starts immediately and appears in
/managekeysas temporary. - Enter an unkeyed vehicle, use txAdmin FIX, and confirm the fixed vehicle is added to
/managekeysas temporary.
If either spawn path requires hotwiring, first confirm GetResourceState('GR1M_Carkeys') is started, then compare both external files with the snippets above.
GR1M