DocsRadial Menu

Vehicle locks

Who may lock a vehicle and how keys work.

Not released yet. These pages are written from the code of manniche_radial and can change before the release.

Who can lock

The client sends only the vehicle's network ID. The server checks the rest and sets the lock. A player can lock when one of these is true:

  1. They own the vehicle in the framework database: owned_vehicles on ESX (owner, or job with jobVehicles), player_vehicles on QBCore and Qbox. This needs oxmysql started.
  2. The state bag owner on the vehicle matches the player, but only when sv_stateBagStrictMode is true.
  3. The owner gave them keys with the key command. Given keys last until the server restarts.
  4. A supported keys script reports that they have keys.
  5. Config.vehicle.driverCanLock is true and they sit in the driver seat.

Ownership lookups are cached for 30 seconds. A player can send a lock request at most every 500 ms. The player must sit in the vehicle or be within lockDistance plus a margin of 3.0 metres.

On a standalone server there is no database ownership. Only given keys, a keys script or driverCanLock allow locking.

Keys

The owner uses /givekey <id> and /removekey <id> next to or in the vehicle. Only the owner can do this. Giving keys also needs the target within giveKeyDistance. Command names come from the config.

Supported keys scripts

With Config.vehicle.keys = 'auto' the first started script in this order is asked:

  • qbx_vehiclekeys
  • Renewed-Vehiclekeys
  • wasabi_carlock
  • vehicles_keys
  • MrNewbVehicleKeys
  • qb-vehiclekeys
  • p_vehiclekeys

Set keys to one of these names to ask only that one, or 'none' to ask none. When qbx_vehiclekeys is started, the lock state is also set through its SetLockState. When p_vehiclekeys is started, the lock is set through its changeLockState, which also flashes the lights.

For any other keys script, set Config.vehicle.lockEvent to a client event that toggles the lock.