You can verify if the script is running by checking for the resource state:
if GetResourceState('ts-persistence') == 'started' then
-- Script is running
end
Warning
Networked Vehicles
All vehicle entities must be networked in order to be persisted. If a non-networked vehicle is passed, the script will return nil or indicate failure.
Exports
IsVehiclePersistenceDisabled
Check if persistence is disabled for a vehicle.
local isDisabled = exports['ts-persistence']:IsVehiclePersistenceDisabled(vehicle)
| Argument | Type | Description |
|---|
vehicle | entity | The vehicle entity to check. |
Returns:
boolean: true if persistence is disabled, false otherwise.
SetVehiclePersistenceDisabled
Enable or disable persistence for a vehicle.
exports['ts-persistence']:SetVehiclePersistenceDisabled(vehicle, state)
| Argument | Type | Description |
|---|
vehicle | entity | The vehicle entity to modify. |
state | boolean | true to disable persistence, false to enable it. |
CreateVehicle
Manually create persistence data for a vehicle. This is usually handled automatically, but can be forced if needed.
local id = exports['ts-persistence']:CreateVehicle(vehicle)
| Argument | Type | Description |
|---|
vehicle | entity | The vehicle entity to persist. |
Returns:
string | nil: The persistence ID if successful, nil otherwise.
UpdateVehicle
Manually update the persistence data for a vehicle.
local success = exports['ts-persistence']:UpdateVehicle(vehicle)
| Argument | Type | Description |
|---|
vehicle | entity | The vehicle entity to update. |
Returns:
boolean | nil: true if successful, nil otherwise.
GetVehiclePersistenceId
Get the persistence ID of a vehicle.
local id = exports['ts-persistence']:GetVehiclePersistenceId(vehicle)
| Argument | Type | Description |
|---|
vehicle | entity | The vehicle entity. |
Returns:
string | nil: The persistence ID if found, nil otherwise.
GetVehiclePersistenceData
Get the full persistence data for a vehicle.
local data = exports['ts-persistence']:GetVehiclePersistenceData(vehicle)
| Argument | Type | Description |
|---|
vehicle | entity | The vehicle entity. |
Returns:
table | nil: The vehicle data table if found, nil otherwise.
The returned table contains information such as:
netId: Network ID
plate: Vehicle plate
coords: Position
hash: Model hash
model: Model name
props: Vehicle properties (mods, colors)
trailer: Trailer data
doorStatus: Door locks
damageData: Health and fuel
deformation: Visual deformation (if plugin enabled)
You can find the detailed breakdown of the returned data structure in the Data Structure page.
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)
| Argument | Type | Description |
|---|
vehicleId | string | nil | The persistence ID of the vehicle (optional if plate is provided). |
plate | string | nil | The plate of the vehicle (optional if vehicleId is provided). |
Returns:
boolean: true if successful, false otherwise.
Last modified on March 5, 2026