Installation
Overview
ml_vehicle_persistence keeps vehicles in the world where they were parked. Parked vehicles survive owner disconnects and server restarts, respawning in place with their mods, colors, fuel and damage. Saved vehicles are held in memory and streamed into the world only when a player comes close, so a server can hold hundreds of them. On a survival server it can also register the first driver of any unowned vehicle as its permanent owner.
Quick Start
- Download from CFX Portal
- Extract to your
resourcesfolder asml_vehicle_persistence - Add to
server.cfg:
1ensure oxmysql
2ensure ox_lib
3ensure ml_bridge
4ensure ml_vehicle_persistenceml_vehicle_persistence must start AFTER ml_bridge.
Database
The table is created automatically on first start. Existing installs are patched in place (missing columns are added on boot).
Table — Purpose
ml_vehicle_persistence — Stores each persisted vehicle: plate, owner, model, position, properties, fuel, damage
The SQL is also shipped in _INSTALL/schema.sql for manual creation.
Item Registration
All three items are optional. Register them in your inventory system for the features you enable:
vehicle_gps: Lists the owner's persisted and garaged vehicles and sets a waypoint. RequiresConfig.GpsItemgps_scanner: Thief tool that locates and rips out a vehicle's GPS. RequiresConfig.GpsScanner.enabledgps_module: Consumed by the owner to reinstall a removed GPS. RequiresConfig.GpsScanner.enabled
The definitions are in _INSTALL/items.lua. Set Config.GpsItem = false and Config.GpsScanner.enabled = false to skip them entirely.
Verify
After starting, the console prints the version banner and the load summary:
1[ml_vehicle_persistence] loaded 0 persisted vehicles (0 already in world)The script needs SetEntityOrphanMode, otherwise the engine can cull spawned vehicles and they would leave persistence. A red console error on boot means the FXServer artifact is too old.
- Vehicles not respawning after restart - confirm
Config.PersistThroughRestart = trueand that the database table has rows - Saved vehicles never appear near the player - raise
Config.SpawnDistanceor lowerConfig.ScanInterval; vehicles only spawn when a player is close - Claimed vehicles never appear - confirm
Config.WorldVehicles.enabled = trueand that the player sat in the driver seat - A script vehicle gets saved when it should not - call
exports.ml_vehicle_persistence:DoNotSave(plate)from the spawning resource - An admin
/dvbrings the vehicle back -Config.RespawnOnExternalDeleteistrue; set it tofalseor route the delete through the hook - Nothing persists at all - enable
Config.Debug = trueand read the console gate messages. A redDATABASE WRITE TEST FAILEDon boot means the table does not match