OPX//77
opx_infinityvehicles

vehicles

Last updated on

Owned vehicles — the plate registry, bringing a car out, putting it away and keeping its condition across restarts.

The registry of what each character owns. It draws plates, writes the rows, creates a car in the world, puts it away and saves its health, damage, paint and fuel tank every few minutes. Players never talk to it directly: they use a garage marker or a dealer, and those modules call this one. Use its contract when your own code needs to give a character a car, list their cars or bring one out.

Sideserver only (the client half does not exist)
Requirescharacter (hard)
Contractvehicles v1 — server
Configconfig/vehicles.lua (server script — never sent to a client)
Dataopx77_vehicles
  • The plate is the identity. A runtime vehicle id belongs to one spawn and is recycled; the plate is the row. Only vehicles this module spawned have a plate: PlateOf answers nothing for a car created by anything else.
  • Every out vehicle is stored again when its owner disconnects, when the owner is no longer loaded at the next save pass, when the host removes it, and when the resource stops.
  • On stop, each car's condition is read and written as stored (one UPDATE per car, at most 64 cars, best effort), then the car is removed. The save pass every SAVE_SECONDS stays the real guarantee.
  • Two stores of the same plate never run at once, and a save pass never writes an old row over a store that has landed. A put-away is announced once.
  • One registration per character at a time. A Register waits for the one in flight for the same character (up to 5 s, then vehicle.registering) and counts again, so two at once cannot pass PER_CHARACTER. A turn held 30 s is released.
  • A character that is deleted loses all its rows (the character delete is soft, so this module deletes them itself).

Configuration

config/vehicles.lua sets OPX.Config.MODULES.vehicles. Server script: no client reads it.

KeyDefaultEffect
enabledtruefalse switches the module off. Garages and dealers then refuse everything.
PER_CHARACTER8Most vehicles one character may own. 0 = no limit.
PLATE_FORMAT'11AAA111'1 draws a digit, A a letter, . either; anything else is copied. ASCII capitals only (the column is ascii_bin, 12 characters wide).
DEFAULT_GARAGE'impound'The garage key a vehicle registered with no garage is filed under.
SPAWN_OFFSET3.0Metres beside the player a car appears when no place is named.
SAVE_SECONDS120How often the condition of every out vehicle is written. Minimum 1 s.

Refusal codes

Each code is also a locale key (English and French) used for the toast.

CodeMeaning
vehicle.notFoundNo such plate, or it is not yours.
vehicle.limitThe character already owns PER_CHARACTER vehicles (detail: the limit).
vehicle.registeringAnother registration for this character did not finish within 5 s.
vehicle.badRecordThe record is longer than 256 characters.
vehicle.plateExhaustedFive plate draws all collided.
vehicle.impoundedThe vehicle is impounded; Spawn refuses it until SetState(plate, 'stored').
vehicle.busyAnother spawn or state change of this plate is in progress.
vehicle.badStateSetState got a state other than stored or impounded.
vehicle.notLoggedInNo character loaded on that connection, or it changed during the spawn (the new car is removed).
vehicle.noPositionThe host would not say where the player is.
vehicle.spawnRefusedOpen77.vehicles.create refused; detail carries its reason.
vehicle.notSpawnedStore on a plate that is not out.
vehicle.storeRefusedThe host would not remove the car; it stays out and the row stays out.
vehicle.occupiedA recall or state change was asked but somebody sits in the car.
error.badRequestMissing or wrong-typed argument.
error.tooFastThe 3 s request cooldown (net events only).

On this page