opx_infinityvehiclekeys
vehiclekeys
Last updated on
Vehicle keys as inventory items, and the host lock a key turns.
Makes a car key an inventory item. Each key is one vehicle_key item whose metadata names the plate it opens. A player holding the key can lock or unlock that car from the target eye (Lock / unlock) or by using the key from their bag, standing within 6 m or sitting in it. Keys are cut automatically when a car is bought or brought out of a garage, and staff can cut one for any vehicle. A locked car cannot be entered and its trunk will not open.
| Side | both |
| Requires | none |
| Optional | vehicles, inventory, target |
| Contract | vehiclekeys v1 — server |
| Config | none (constants in modules/vehiclekeys/module.lua) |
| Data | none of its own; keys are vehicle_key items in inventory |
- Without
inventory(or an inventory withoutCountWhere) no key is ever cut and no lock can be turned. - Without
vehiclesevery vehicle gets a minted plate. - Without
targetthere is no row, but a key still works from the bag.
How keys work
- The item.
vehicle_key: weight 20, categorytool, does not stack, using it consumes nothing. Metadata{ plate, label }, wherelabelis<model> · <plate>(for exampleVillefort Cortes · 12ABC345), or the plate alone. Only the server writes it. - The plate is the identity. An owned vehicle uses its real plate. A vehicle
vehiclesnever registered (a staff spawn, a showroom car, another resource's car) gets a minted plate,TMP-plus six characters, the first time a key is cut for it. A minted plate is held in memory only and is forgotten when the host removes the vehicle; its keys then open nothing. Plates are matched exactly as written, byte for byte: nothing is upper-cased or trimmed, so a legacy plate such asABC 123keeps its space. - Who gets a key.
- The buyer, on every dealership sale.
- The owner, when a garage brings the car out and their bag holds no key to that plate.
- The player a staff spawn was made for, and a staff member using
/opx.admin.vehicle.key. - A full bag is told to the player (
vehiclekeys.noRoom) and never refuses the sale or the take-out.
- What a key does. It flips the host's replicated entry lock (
Open77.vehicles.setLocked). The server checks: the vehicle exists, the player sits in it or stands within 6 m in the same bucket, and their bag holds a key whose plate is that vehicle's. A trunk or glovebox key does not count. On success the horn chirps and a toast says locked or unlocked. A locked vehicle's trunk is refused by the inventory module. - The target row is
vehiclekeys.toggle(Lock / unlock), on vehicles, 6 m, shown only when the bag holds at least one key; its checkbox shows the replicated lock state.
Refusal codes
Each code is also a locale key (English and French).
| Code | Meaning |
|---|---|
vehiclekeys.noVehicle | No live vehicle with that id, or the used key has no plate. |
vehiclekeys.notOut | The vehicle the used key opens is not in the world. |
vehiclekeys.tooFar | Not seated in it and further than 6 m plus REACH_SLACK (7 m by default), or in another bucket. |
vehiclekeys.noKey | No key to that vehicle in the bag. |
vehiclekeys.lockRefused | The host refused the lock change, cannot read the lock, or the lock native raised. |
vehiclekeys.noRoom | The bag is full or too heavy for the key (detail: the key label). |
vehiclekeys.unavailable | No inventory, or the item could not be added for another reason. |
vehiclekeys.tooFast | Toggle cooldown (toast only). |
error.incapacitated | The player is down: no lock turned from the floor. |
error.badRequest | The plate is not a valid plate: 1–16 printable ASCII characters, not only blanks. |