ktoxktox docs

Vehicle Persistence

How vehicle persistence works across different frameworks.

Vehicle Persistence

When enabled, vehicles taken out of garages stay in the world permanently. They survive player disconnects and server restarts.

QBox

QBox controls persistence through its own convar. The persistVehicles config setting is ignored.

Enable in server.cfg:

set qbx:enableVehiclePersistence true

QBox supports two persistence modes via the convar value:

  • true or "semi" - vehicles respawn when deleted
  • "full" - vehicle position is saved every 30 seconds

ktx_garages calls exports.qbx_core:EnablePersistence() for each vehicle taken out of a garage.

Warning: If persistVehicles = true is set in config but the QBox convar is disabled, persistence will NOT work. The server console will log a warning about this mismatch.

ox_core

Persistence is always enabled regardless of the config setting. ox_core handles the vehicle entity lifecycle, including orphan mode and restart respawning. Vehicles are spawned through ox_core's API.

ESX / Default

Set in shared/config.lua:

Config.GarageSystem = {
    persistVehicles = true,
}

How it works:

  • Vehicle positions are saved to the database every 30 seconds
  • When a player gets within 200 units of a saved vehicle location, the vehicle spawns
  • If the vehicle entity is removed, it re-queues for proximity-based respawn
  • On txAdmin scheduled restarts, all vehicle positions are saved at the 60-second warning

When Persistence is Disabled

  • Vehicles are removed when the player disconnects or the server restarts
  • Vehicles are deleted when they leave entity scope with no nearby players

Exports for External Scripts

Other resources (dealerships, admin tools, etc.) can make vehicles persistent without going through a garage.

-- Make a vehicle persistent (server-side)
exports.ktx_garages:persistVehicle(vehicleEntity, plate)

-- Stop tracking a vehicle
exports.ktx_garages:unpersistVehicle(plate)

-- Check if a vehicle is tracked
local tracked = exports.ktx_garages:isVehiclePersisted(plate)

Note: These exports only work when persistence is active for your framework. They have no effect if persistence is disabled.