Skip to content

Reference

Owned vehicles ​

Table rlx_vehicles: unique plate, owner (citizenid), model, full properties, garage, stored or out.

lua
local plate = RLX.AddVehicle(xPlayer.citizenid, "sultan", { garage = "pillbox", props = { color1 = 12 } })
local list = xPlayer.getVehicles()                      -- or RLX.GetVehiclesByOwner(citizenid)
local netId = RLX.SpawnOwnedVehicle(plate, { x = 215.0, y = -800.0, z = 30.5, heading = 70.0 }, { owner = source, warp = true })
local props = RLX.GetVehicleProperties(source, netId)   -- read by the player's game
RLX.StoreVehicle(plate, props, "pillbox")              -- stored, properties kept
Function
RLX.GetVehicle(plate){ plate, owner, model, props, garage, stored, netId }
RLX.SetVehicleProperties(plate, props) · SetVehicleGarage(plate, garage, stored) · SetVehicleOwner(plate, cid) · RemoveVehicle(plate)
RLX.SpawnVehicle(model, coords, { owner, warp, props, plate, keep })A non-owned vehicle, with properties.
RLX.GetVehiclePlate(netId) · RLX.GetSpawnedVehicle(plate) · RLX.GeneratePlate()

The properties (colors, pearl, wheels, windows, parts, turbo, xenon, extras, neons, livery, plate, engine and body health, fuel, dirt) are applied by every client as soon as the vehicle appears.

Persistent vehicles (Config.Vehicles.persistent, on by default): an owned vehicle left out stays where it was left: after its owner leaves, after a crash of the game, after a restart of the server.

  • Every persistSeconds (20) the server notes its place, heading (from the sync data), instance and lock, and its engine and body health (read by the server itself). Column location of rlx_vehicles.
  • The full damage (broken windows and doors, burst tyres, fallen bumpers, tank, and the dents, measured on a grid around the model) is reported by the game that simulates the vehicle (its driver, or a player near it when parked) whenever it changes: a crash, shots, a repair. The server keeps only the damage from it (never the looks).
  • The damage is kept apart from the looks (entity meta rlx:damage) and every game that sees the vehicle puts it back (harmless when it is already there: a dent is only hit while it is shallower than saved). A player who disconnects does not take the vehicle away: it is the same entity, with its damage, for everyone. After a restart of the server the vehicle is a new entity: the same model, the same place and heading, its looks and damage put back.
    • Dents: GTA does not let a script read or write the shape of a body, only how deep it is dented at a point. The game measures 30 points (3 across, 5 along, bottom and top); they are rebuilt by hitting from outside until each point is as deep as saved. Only the points still too shallow are hit (a vehicle seen again, already dented: nothing to do), within about a second, and a vehicle that just appeared stays hidden on that screen meanwhile: nobody sees it being dented. Very close, not identical to the millimetre.
    • Heading: the game that simulates the vehicle turns it the way it was parked (entity meta rlx:restore, kept 2 minutes, as long as nobody moved it).
  • Its entity disappears without being stored (a crash, the game cleaning the area): it comes back at its last place.
  • The server starts: every vehicle out comes back where it was (after a hot reload of rlx, the entities still there are taken back as they are).
  • Destroyed (blown up, wrecked): out of the world, at the impound (rlx_garage); its owner is told. /dv on an owned vehicle: to the impound too.
  • Events rlx:vehicleRestored (plate, netId), rlx:vehicleLost (plate, why: wrecked, dv). persistent = false: vehicles left out go back to their garage when the server starts.
  • Your own persistence: hook vehicleRestore (plate, citizenid, model, place): return false to keep a vehicle from coming back, or change place.