T2 // Vehicles & Fleet

coe_vehicles

Fleet Synchronization, Damage & Tuning

Permanent Damage Persistence, Garages & Visual Tuning Modifications

HEADLESS SERVICE (NO UI)
DEPENDS ON coe_corecoe_databasecoe_vehicle_catalogcoe_ui
coe_vehicles 19 exports · 4 commands

Runs without a NUI: nothing is rendered on the client and the resource stays idle until events arrive.

01 // OVERVIEW

Governs the entire lifecycle of citizen vehicles. Persists body panel denting, shattered glass, engine oil levels, brake pad wear, and fuel volume directly into MariaDB. Features public and private residential garages, digital wireless key locks, and comprehensive performance tuning.

On FiveM Enhanced

Harnesses FiveM Enhanced server-authoritative networked entities, completely eliminating vehicle desync or despawns when looking away.

02 // FEATURES

What the module delivers

01

Permanent Damage Persistence

Vehicles emerge from garages retaining exact body deformations and mechanical wear.

02

Encrypted Digital Key Fob

Lock and unlock remotely; share digital guest keys with friends and faction members.

03

Mileage Wear & Maintenance

Engine oil, brake discs, and clutch require periodic servicing at mechanic shops.

04

RGB Visual Tuning & Parts

Custom chameleon paint codes, bodykits, and turbocharger upgrades stored in database.

ARCHITECTURAL LAYERS // CLEAN ARCHITECTURE

4-Layer Isolation with 0.00 ms Idle

Every COE Framework script strictly follows the principle of separation of concerns. Interact with the 3D stack below:

L4
Headless Operation (No UI)
Zero DOM · CoE UI Delegation
Headless
L3
Application & Server
Atomic locks · Rate limiting
Auth Server
L2
Platform & HAL
Core.Platform · Mock natives
Gen9 HAL
L1
Domain & ACID Database
Prepared SQL · MariaDB pool
ACID Pool
LAYER 04 // HEADLESS SERVICE

Headless Service (No Dedicated NUI)

Operates strictly within layers L1–L3 (domain, HAL, and server-authoritative application logic). Visual interactions and management flows are delegated to centralized ecosystem apps (coe_ui / coe_tablet), guaranteeing 0.00 ms idle client overhead in FiveM DX12.

Zero CEF graphic overhead: no background web pages or NUI bridges loaded
Typed public contracts (types.lua) consumed directly by external resources and UIs
Strict adherence to the Server-Authoritative model with zero direct DOM manipulation
ADMIN POWERS // OPERATION & MANAGEMENT

What this script delivers to Server Owners

Manage your city without relying on developers. Runtime parameters, auditing, and ACE-protected commands:

🛡️
ACE Permissions
Administrative operations strictly protected by coe.staff and coe.admin principals.
IsPlayerAceAllowed(src, "coe.admin")
📊
Ledger Auditing
Relevant actions write audit records to the database through coe_audit.
exports.coe_audit:Record(severity, category, event, context)
⚡
0.00ms Idle Telemetry
Event-driven thread dispatch that stays dormant until network events fire.
Clean Architecture & HAL
03 // EXPORTS

Public API 19

Typed contracts to call from other resources. Full types live in types.lua and in the docs reference.

exports['coe_vehicles']:Create(data) → CoeVehicle|string

Creates an authoritative vehicle record in MariaDB. Restricted to `WriterResources`.

ParameterType
dataCoeVehicleCreate
LUA
local result = exports['coe_vehicles']:Create(data)
exports['coe_vehicles']:Get(vehicleId) → CoeVehicle|string|nil

Retrieves a vehicle record by its unique database ID.

ParameterType
vehicleIdstring
LUA
local result = exports['coe_vehicles']:Get(vehicleId)
exports['coe_vehicles']:GetByPlate(plate) → CoeVehicle|string|nil

Retrieves a vehicle record by its license plate string.

ParameterType
platestring
LUA
local result = exports['coe_vehicles']:GetByPlate(plate)
exports['coe_vehicles']:ListByOwner(characterId) → CoeVehicle[]|string

Lists all vehicles owned by a specific character.

ParameterType
characterIdstring
LUA
local result = exports['coe_vehicles']:ListByOwner(characterId)
exports['coe_vehicles']:GetEntity(vehicleId) → integer|nil

Returns the server-side FiveM entity handle if the vehicle is currently spawned in the world.

ParameterType
vehicleIdstring
LUA
local result = exports['coe_vehicles']:GetEntity(vehicleId)
exports['coe_vehicles']:GetMileage(vehicleId) → number|string

Returns the cumulative vehicle odometer reading in integer meters.

ParameterType
vehicleIdstring
LUA
local result = exports['coe_vehicles']:GetMileage(vehicleId)
exports['coe_vehicles']:SetMileage(vehicleId, meters) → true|string

Calibrates odometer reading (persists immediately with audit entry). Restricted to `MileageEditors`.

ParameterType
vehicleIdstring
metersnumber
LUA
local result = exports['coe_vehicles']:SetMileage(vehicleId, meters)
exports['coe_vehicles']:Spawn(vehicleId, x, y, z, heading, vehicleType) → number|string

Spawns vehicle entity into the world, registers it with tracking state, and begins mileage accumulation.

ParameterType
vehicleIdstring
xnumber
ynumber
znumber
headingnumber
vehicleTypestring|nil
LUA
local result = exports['coe_vehicles']:Spawn(vehicleId, x, y, z, heading, vehicleType)
exports['coe_vehicles']:Store(vehicleId) → true|string

Flushes pending odometer distance, despawns the world entity, and transitions vehicle state to `stored`.

ParameterType
vehicleIdstring
LUA
local result = exports['coe_vehicles']:Store(vehicleId)
exports['coe_vehicles']:IsReady() → boolean

Verifies if vehicle tables and migrations are ready for transactions.

No parameters.

LUA
local result = exports['coe_vehicles']:IsReady()
exports['coe_vehicles']:HasKey(characterId, vehicleId) → boolean

Checks if a character holds digital key access. The owner inherently has key access; additional shared keys are queried from `coe_vehicle_keys`.

ParameterType
characterIdstring
vehicleIdstring
LUA
local result = exports['coe_vehicles']:HasKey(characterId, vehicleId)
exports['coe_vehicles']:GiveKey(vehicleId, characterId) → true|string

Grants a digital key to a borrower character. Restricted to `WriterResources`.

ParameterType
vehicleIdstring
characterIdstring
LUA
local result = exports['coe_vehicles']:GiveKey(vehicleId, characterId)
exports['coe_vehicles']:RevokeKey(vehicleId, characterId) → true|string

Revokes a borrowed digital key. Restricted to `WriterResources`.

ParameterType
vehicleIdstring
characterIdstring
LUA
local result = exports['coe_vehicles']:RevokeKey(vehicleId, characterId)
exports['coe_vehicles']:ListKeyHolders(vehicleId) → string[]|nil

Lists all borrower character IDs (excluding the owner) holding digital keys to this vehicle.

ParameterType
vehicleIdstring
LUA
local result = exports['coe_vehicles']:ListKeyHolders(vehicleId)
exports['coe_vehicles']:TransitionState(vehicleId, expectedState, nextState) → true|string

Transiciona atomicamente o estado do veículo. Somente WriterResources.

ParameterType
vehicleIdstring
expectedStatestring
nextStatestring
LUA
local result = exports['coe_vehicles']:TransitionState(vehicleId, expectedState, nextState)
exports['coe_vehicles']:SetHousingVehiclePhase(vehicleId, expected, target) → boolean, string|nil

Altera a fase de manutenção de um veículo estacionado em garagem residencial/oficina. Somente WriterResources.

ParameterType
vehicleIdstring
expectedstring
targetstring
LUA
local ok, detail = exports['coe_vehicles']:SetHousingVehiclePhase(vehicleId, expected, target)
exports['coe_vehicles']:IsHousingVehicle(vehicleId) → boolean

Verifica se o veículo está estacionado fisicamente em garagem residencial. Somente WriterResources.

ParameterType
vehicleIdstring
LUA
local result = exports['coe_vehicles']:IsHousingVehicle(vehicleId)
exports['coe_vehicles']:ResumeHousingVehicle(vehicleId) → boolean, string|nil

Retoma o estado de veículo estacionado em garagem residencial após manutenção. Somente WriterResources.

ParameterType
vehicleIdstring
LUA
local ok, detail = exports['coe_vehicles']:ResumeHousingVehicle(vehicleId)
exports['coe_vehicles']:RecoverHousingLocks() → boolean, string|nil

Recupera travas de manutenção pendentes após reinício. Somente WriterResources.

No parameters.

LUA
local ok, detail = exports['coe_vehicles']:RecoverHousingLocks()
04 // COMMANDS

In-game commands 4

/chave_emprestar <id do jogador>

Lends the key of the nearest vehicle you own to a nearby player.

/chave_retirar <id do jogador>

Revokes the lent key of the nearest vehicle.

/coe_vehicle_create <modelo> [placa]

Test tool: creates a vehicle for the active character. ACE command.coe_vehicle_create.

/coe_vehicle_mileage <placa> <km>

Sets a vehicle mileage. ACE command.coe_vehicle_mileage.