ai-vehiclekeys
Vehicle keys, locking with a key fob, lockpicking and hotwiring, and the engine block without a key.
ai-vehiclekeys decides who may lock, unlock and start a vehicle. A player without the key cannot start the engine; with a lockpick they can try to open a locked door or hotwire the car.
What it does in the game
- Who has a key. The owner of an owned vehicle always has its key, and every member of the job or gang that owns a fleet vehicle has it too. These keys are never stored: they follow ownership in ai-vehicles, so selling a car moves the key with it. Other scripts can give extra keys (a rental, a job vehicle, a test drive, an admin spawn); those last until the player leaves the server or switches character.
- Locking. Press U near a vehicle you have the key to. The lights flash and the horn beeps once when you are on foot.
- Engine. In the driver seat without a key, the engine stays off: the player cannot start it by accelerating, and the radial menu's engine item refuses too. M switches the engine off and on again for a driver who has the key.
- Handing over keys. Sitting in a vehicle you hold the key of, the radial menu's vehicle section shows Hand over the keys. The nearest other player within 3 m gets a copy (you keep yours). Both get a notification.
- Lockpicking. Use a
lockpickitem next to a locked vehicle (within 3 m) to open its doors. Use it in the driver seat of a vehicle you have no key to, to hotwire it: on success the player holds the key until leaving the server. The order is: the minigame (if one is set), a progress bar, then the chance roll. The player must stay within 4 m of the vehicle until the end. A failed try may break the lockpick.
Installation
Installed by the AI Core recipe. By hand: ensure ai-vehiclekeys after ai-core and ai-vehicles. Add a lockpick item to your inventory if it has none: ai-vehiclekeys registers it as usable with whichever inventory runs.
In the admin panel, Server > General > Key script picks the key system. Automatic uses ai-vehiclekeys when no other supported key script runs.
Panel settings
Admin panel > Vehicle keys > tab Keys and locks. Defaults come from data/settings.json.
Lock key
| Setting | What it changes | Unit | Default |
|---|---|---|---|
| Lock reach | How close the player must be to the vehicle to lock or unlock it. 2-30. | m | 6 |
Lockpicking
| Setting | What it changes | Unit | Default |
|---|---|---|---|
| Door chance | Chance a lockpick opens a locked door. 0-100. | % | 60 |
| Door time | How long the progress bar for a door runs. 1-60. | s | 5 |
| Hotwire chance | Chance the engine starts; the player then has the keys until leaving the server. 0-100. | % | 35 |
| Hotwire time | How long the progress bar for hotwiring runs. 1-120. | s | 10 |
| Break chance | Chance the lockpick breaks when a try fails. 0-100. | % | 25 |
| Minigame | Played before the progress bar: None, Skill check or Lockpick. A lockpick that breaks in the lockpick game is used up. The chance above is still rolled after a won game: set it to 100 % to let the game decide alone. | Lockpick | |
| Difficulty | Easy, Medium or Hard. Shown only when a minigame is picked. | Medium |
Commands
None.
Keybinds
Each player can change these in GTA's key settings (FiveM section); the owner changes the defaults in the admin panel (Keybinds).
| Default key | What it does |
|---|---|
| U | Lock or unlock the nearest vehicle you have the key to. |
| M | Engine on / off (driver seat only). Without a key it shows "You do not have the keys to this vehicle". |
What it stands in for
fxProvide: qbx_vehiclekeys. exports.qbx_vehiclekeys:HasKeys, GiveKeys, RemoveKeys, SetLockState and IsPlayerNearVehicle reach ai-vehiclekeys.
Other key scripts
You can run another key script instead: AI Core's key layer talks to qbx_vehiclekeys, qb-vehiclekeys, wasabi_carlock, Renewed-Vehiclekeys, MrNewbVehicleKeys, vehicles_keys (Jaksam), mVehicle, cd_garage's keys and tgiann-hotwire. Pick it in the admin panel (Server > General > Key script) and stop ai-vehiclekeys. Every ai-* script gives keys through the layer, so they keep working.
Known limits
- Extra keys (hotwired, handed over, given by scripts) last only for the session: they are gone when the player leaves or switches character.
- Lockpicking needs the
lockpickitem to exist in your inventory's item list.