Gameplay
Medit8z Gun Rack has two access paths — the officer path for on-duty allowed jobs, and the civilian path for any player who has acquired a gunrack_key. Every action is server-validated.
Officer flow
Install
- An on-duty officer (job in
Config.AllowedJobs) stands withinMaxInstallDistanceof a parked vehicle whose class matchesConfig.AllowedVehicleClass. - The officer uses the
gunrackitem from inventory. - The driver door opens and a 5-second
ox_libprogress bar runs. - On completion the
gunrackitem is consumed, a row is inserted into thegunrackstable keyed by plate, and a fresh Ox Inventory stash is registered for the plate.
If the player isn't on an allowed job, isn't near an allowed-class vehicle, or the plate already has a rack, the install is rejected and the item is not consumed.
Open (authorized)
On-duty officers open the stash from inside the vehicle, typically via your target script firing the medit8z_gunrack:server:open event with the plate. Officers do not need a gunrack_key.
Uninstall
- An on-duty officer sits inside the vehicle.
- The officer runs
/removegunrack. - The server validates job, plate, and stash contents.
- If the stash is empty, the rack is removed from the database and the
gunrackitem is returned to the officer's inventory.
Uninstall is rejected if the stash contains any items. Move all weapons out first — this is a safety guard, not a bug.
| Command | Effect |
|---|---|
/removegunrack | Uninstall the rack from the current vehicle. Job-locked, empty-only. |
Civilian flow
Civilians (any player whose job is not in Config.AllowedJobs) interact with installed racks via the gunrack_key item.
- The civilian sits inside a vehicle that already has a rack installed on its plate.
- The civilian uses a
gunrack_key. - The key is consumed and the stash opens for one access.
- Closing the stash ends access — opening it again requires another key.
This is intended to drive the "stolen squad car / lost equipment" RP loop: officers leave weapons in the rack, the vehicle gets jacked, the thief needs a key (loot, craft, or buy) to crack it, and every key is one-shot.
Persistence
- Each plate maps to exactly one rack — the
gunracks.platecolumn has aUNIQUEconstraint, and the script also rejects double-installs at the application layer. - Stash contents are owned by Ox Inventory and persist across restarts via its standard stash storage.
- On every server start, every row in
gunracksis re-registered as an Ox Inventory stash, so the rack is immediately accessible after a restart. - Removing a vehicle from the world does not remove its rack — only
/removegunrack(with an empty stash) deletes the row.
Edge cases
| Situation | Behavior |
|---|---|
| Two racks on the same vehicle | Rejected — UNIQUE plate constraint plus app-level guard. |
| Lightbar utility prop is class 18 | Add its model prefix to Config.IgnoredModelPrefixes. |
| Civilian uses a key with no installed rack | Rejected — key is not consumed. |
| Officer uninstalls a rack with weapons inside | Rejected — must empty first. |
| Vehicle is destroyed / impounded | Rack row remains; reissuing the same plate restores access to the original stash. |
See Troubleshooting for failure-case fixes.