Skip to main content
You can verify if the script is running by checking for the resource state:
if GetResourceState('ts-persistence') == 'started' then
    -- Script is running
end

Exports

DeleteVehicleEntity

Deletes the vehicle entity from the game world, but keeps its data in the database.
exports['ts-persistence']:DeleteVehicleEntity(vehicleId)
ArgumentTypeDescription
vehicleIdstringThe unique persistence ID of the vehicle.

GetAllVehicles

Get a list of all vehicles currently loaded by the persistence system.
local vehicles = exports['ts-persistence']:GetAllVehicles()
Returns:
  • table: A dictionary of all active vehicles.

DoesVehicleExistInDb

Check if a vehicle exists in the database.
local exists = exports['ts-persistence']:DoesVehicleExistInDb(vehicleId)
ArgumentTypeDescription
vehicleIdstringThe persistence ID of the vehicle.
Returns:
  • boolean: true if it exists, false otherwise.

Reload

Reload all vehicles from the database and refresh the system.
exports['ts-persistence']:Reload()

UpdateVehiclePos

Update the position of a persistent vehicle in memory.
exports['ts-persistence']:UpdateVehiclePos(vehicleId, coords, heading)
ArgumentTypeDescription
vehicleIdstringThe persistence ID of the vehicle.
coordsvector3The new coordinates.
headingnumberThe new heading.

UnloadAllVehicles

Deletes all persistent vehicle entities from the game world (does not remove their data from the database).
exports['ts-persistence']:UnloadAllVehicles()

SetVehicleDeleteAt

Set a Unix timestamp for when the vehicle should be automatically deleted from the database.
exports['ts-persistence']:SetVehicleDeleteAt(vehicleId, timeTimestamp)
ArgumentTypeDescription
vehicleIdstringThe persistence ID of the vehicle.
timeTimestampnumberThe Unix timestamp for deletion.

DeleteVehicleFromDB

Delete a vehicle from the persistence database using its ID.
exports['ts-persistence']:DeleteVehicleFromDB(vehicleId)
ArgumentTypeDescription
vehicleIdstringThe persistence ID of the vehicle to delete.

DeleteVehicleFromDBByPlate

Delete a vehicle from the persistence database using its plate.
exports['ts-persistence']:DeleteVehicleFromDBByPlate(plate)
ArgumentTypeDescription
platestringThe plate of the vehicle to delete from the database.

ForgetVehicle

Forget the persistence entry for a vehicle, completely removing it from the persistent system and the database.
local success = exports['ts-persistence']:ForgetVehicle(vehicleId, plate, deleteEntity)
ArgumentTypeDescription
vehicleIdstring | nilThe persistence ID of the vehicle (optional if plate is provided).
platestring | nilThe plate of the vehicle (optional if vehicleId is provided).
deleteEntityboolean | nilIf true and the vehicle is currently spawned, its entity will also be deleted from the world. Defaults to false.
Returns:
  • boolean: true if successful, false otherwise.
Last modified on March 11, 2026