Persistent Vehicles Lite
Vehicles ยท Lite

LV Persistent Vehicles Lite

A complete persistent vehicle system for FiveM: your cars stay in the world, save state to MySQL, include a cinematic dealership, configurable garages and a built-in key system.

ESX QBCore Standalone oxmysql OneSync

Introduction

LV Persistent Vehicles Lite is the official LV Scripts resource for servers that need real vehicle persistence without heavy external dependencies. Every purchased or spawned vehicle is stored in the database with position, damage, fuel, colors and lock state.

Unlike basic solutions, this script never deletes abandoned vehicles, restores the world after server or resource restarts, and optimizes performance with OneSync-compatible distance streaming.

Resource: lv-persistent-vehicles-lite ยท Store product: lv-persistent-vehicles-lite ยท Auth: license key + server IP

Features

๐Ÿ’พ MySQL persistence

Position, rotation, colors, damage, fuel, lock state and JSON props in lv_pv_vehicles.

๐Ÿช Dealership

Private showroom with routing buckets, visual customization, test drive and bank/cash purchase.

๐Ÿ…ฟ๏ธ Garages

Multiple public garages in config/garages.lua. Store and retrieve vehicles with the E zone.

๐Ÿ”‘ Key system

Lock with U, animation, lights and sound. Share or revoke keys between players.

๐Ÿ“ก OneSync streaming

Configurable spawn/despawn radius. Data stays in the DB even when the entity is inactive.

โšก Smart saving

Writes to the DB only when there are real changes (dirty flags). Less MySQL load.

Requirements

ComponentRequiredNotes
FiveM + OneSyncYesInfinity or Legacy with extended distance recommended
oxmysqlYesMySQL connection in server.cfg
ox_libNoImproves client notifications
ESX / QBCore / StandaloneOneAuto-detect with Config.Framework.Type = 'auto'
LV Scripts licenseYesGenerated at lvscripts.net bound to server IP

Installation

  1. Copy the resource into your resources/ folder:
    resources/lv-persistent-vehicles-lite/
  2. Database โ€” run the SQL (also auto-installs on start):
    lv-persistent-vehicles-lite/sql/install.sql
  3. server.cfg โ€” recommended order:
    set mysql_connection_string "mysql://user:pass@localhost/dbname?charset=utf8mb4"
    ensure oxmysql
    ensure lv-persistent-vehicles-lite
  4. Configure config.lua with your license, framework and garage/dealership locations.
  5. Restart the server and check the console for successful license verification.
Without a valid license the script will not start: dealership, garage and persistence are disabled.

License

The license is generated in your LV Scripts panel after purchase. It must be bound to your FiveM server public IP.

Config.License = {
    Key = 'LV-XXXX-XXXX-XXXX',
    ApiBase = 'https://lvscripts.net',
    RecheckInterval = 300000,
}

Enable Config.General.Debug = true temporarily to see the verification URL and API response in the server console.

Script strings (notifications, UI) are edited in locale.lua (plaintext file). Language: Config.UI.Locale = 'es' or 'en'.

Configuration

Persistence

Config.Persistence = {
    SaveInterval = 60,
    SaveOnExitVehicle = true,
    SaveOnPlayerDrop = true,
    SaveOnResourceStop = true,
    FullVehicleState = true,
    DeleteAbandoned = false,
    SpawnOnStart = true,
    UseRoutingBuckets = true,
}

Streaming (OneSync)

Config.Streaming = {
    Enabled = true,
    SpawnRadius = 350.0,
    DespawnRadius = 450.0,
    TickMs = 2500,
}

Dealership

Default location: PDM Legion Square. Customize in Config.Dealership:

  • Entrance โ€” player entry point
  • Showroom โ€” vehicle, camera and player preview position
  • TestDrive โ€” duration, spawn and return point
  • PaymentAccount โ€” 'bank' or 'cash' (ESX/QBCore)
  • UseAllGtaVehicles โ€” full GTA catalog or filtered list

Garages

Define garages in config/garages.lua. Each garage includes menu coords, store zones, spawn points and blips.

Keys

Config.Keys = {
    LockToggle = 'U',
    Interact = 38,
}

Dealership catalog

Edit config/gta_vehicles.lua or use Config.VehicleOverrides / Config.VehicleBlacklist.

Frameworks

Config.Framework = {
    Type = 'auto',
    AutoDetect = true,
}
FrameworkDetectionPayment account
QBCoreqb-coreQBCore Cash / Bank
ESXes_extendedESX Cash / Bank
StandaloneNo frameworklicense: identifier

With auto, detection order is: QBCore โ†’ ESX โ†’ Standalone.

QBCore keys: if you use qb-vehiclekeys, set Config.KeySystem.UseQBVehicleKeys = true. By default the script uses its own LV key system.

In-game usage

ActionHow to
Enter dealershipGo to purple blip (PDM) โ†’ press E
Buy vehicleSelect model, customize colors, confirm purchase
Test driveFrom showroom โ†’ Test Drive button (60 s default)
Open garageParking blip โ†’ E at marker
Store vehicleDrive to green garage zone โ†’ E
Lock / unlockNear vehicle โ†’ U

After restart

  • Vehicles outside garage respawn at their last saved position.
  • Vehicles in garage (stored = 1) stay in DB without a world entity.
  • When the resource stops, entities are removed but data persists in MySQL.

Commands

CommandDescription
/darllave [id]Share keys to your nearby vehicle with another player (server ID)
/quitarllaveRevoke shared keys from the current vehicle

Exports (server)

Integrate with other resources using server exports:

local data = exports['lv-persistent-vehicles-lite']:GetVehicleData(vehicleId)
local vehicle = exports['lv-persistent-vehicles-lite']:GetVehicleByPlate('ABC 123')

Returned data includes owner, model, position, garage state, fuel, damage and JSON properties.

Database

TableContents
lv_pv_vehiclesPersistent vehicles: owner, plate, model, coords, fuel, damage, stored, props JSON...
lv_pv_keysShared keys between players per vehicle

The SQL installer creates indexes on owner and plate for fast queries with many vehicles.

Troubleshooting

Script won't start / invalid license

  • Ensure the server public IP matches the license at lvscripts.net.
  • Check Config.License.Key has no extra spaces or quotes.
  • Enable Config.General.Debug = true and review the server console.

Vehicles don't persist

  • Confirm oxmysql is connected (ensure oxmysql before the resource).
  • Check that lv_pv_vehicles tables exist in your DB.
  • Verify Config.Persistence.SpawnOnStart = true.

Dealership or garage not showing

  • License must be active (without it all gameplay is disabled).
  • Review coords in Config.Dealership and config/garages.lua.
  • Check Config.Blips.Enabled and Config.WorldMarkers.Enabled.

Performance with many vehicles

  • Adjust SpawnRadius / DespawnRadius for your population and hardware.
  • Increase SaveInterval if you have thousands of active vehicles.
  • Use garages often to keep vehicles at stored = 1.
Still need help? Open a ticket on our Discord or email contacto@lvscripts.com.