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.
| Side | server only (the client half does not exist) |
| Requires | character (hard) |
| Contract | vehicles v1 — server |
| Config | config/vehicles.lua (server script — never sent to a client) |
| Data | opx77_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:
PlateOfanswers 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(oneUPDATEper car, at most 64 cars, best effort), then the car is removed. The save pass everySAVE_SECONDSstays 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
Registerwaits for the one in flight for the same character (up to 5 s, thenvehicle.registering) and counts again, so two at once cannot passPER_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.
Refusal codes
Each code is also a locale key (English and French) used for the toast.
| Code | Meaning |
|---|---|
vehicle.notFound | No such plate, or it is not yours. |
vehicle.limit | The character already owns PER_CHARACTER vehicles (detail: the limit). |
vehicle.registering | Another registration for this character did not finish within 5 s. |
vehicle.badRecord | The record is longer than 256 characters. |
vehicle.plateExhausted | Five plate draws all collided. |
vehicle.impounded | The vehicle is impounded; Spawn refuses it until SetState(plate, 'stored'). |
vehicle.busy | Another spawn or state change of this plate is in progress. |
vehicle.badState | SetState got a state other than stored or impounded. |
vehicle.notLoggedIn | No character loaded on that connection, or it changed during the spawn (the new car is removed). |
vehicle.noPosition | The host would not say where the player is. |
vehicle.spawnRefused | Open77.vehicles.create refused; detail carries its reason. |
vehicle.notSpawned | Store on a plate that is not out. |
vehicle.storeRefused | The host would not remove the car; it stays out and the row stays out. |
vehicle.occupied | A recall or state change was asked but somebody sits in the car. |
error.badRequest | Missing or wrong-typed argument. |
error.tooFast | The 3 s request cooldown (net events only). |