# qb-diving: diving gear, coral collection and sale

`qb-diving` lets players use diving equipment to collect coral and sell it through configured locations. This page is pinned to [commit 6447b72](https://github.com/qbcore-fivem/qb-diving/tree/6447b72e56552a4e11a3bcd79631effaaed87bc7). The resource does **not** implement a generic scuba certification, procedurally generated treasure registry or SQL log system.

## Install and configure

The [manifest](https://github.com/qbcore-fivem/qb-diving/blob/6447b72e56552a4e11a3bcd79631effaaed87bc7/fxmanifest.lua) loads QBCore locale helpers, `config.lua`, a server script, the client script and two PolyZone client modules. Ensure `qb-core`, `PolyZone` and the inventory/item dependencies actually used by your deployment start first.

The source registers usable items `diving_gear` and `diving_fill`. Ensure both names exist in the installed item list, then test with an actual client.

## Actual configuration

The [`config.lua`](https://github.com/qbcore-fivem/qb-diving/blob/6447b72e56552a4e11a3bcd79631effaaed87bc7/config.lua) defines:

| Key | Role |
| --- | --- |
| `Config.UseTarget` | Toggles target interactions using the server convar |
| `Config.CopsChance` | Chance of triggering a police notification |
| `Config.OxygenLevel` | Diving oxygen behavior |
| `Config.RemoveDivingGear` | Whether the diving gear item is consumed |
| `Config.CoralLocations` | Collectible coral positions/availability |
| `Config.CoralTypes` | Coral item types |
| `Config.BonusTiers` | Reward calculations for quantities |
| `Config.SellLocations` | Coral buyer locations |

Change coral entries in the existing config and verify spawn coordinates and the item table. Do not invent `Config.TreasureRespawnTime`, `Config.MaxDivingDepth`, `Config.RentalLocations` or `Config.CertificationLevels` for this version.

## Events, callbacks and exports

The [client code](https://github.com/qbcore-fivem/qb-diving/blob/6447b72e56552a4e11a3bcd79631effaaed87bc7/client.lua) registers `qb-diving:client:UseGear`, `SetOxygenLevel`, `NewLocations`, `UpdateCoral` and `CallCops`.

The [server code](https://github.com/qbcore-fivem/qb-diving/blob/6447b72e56552a4e11a3bcd79631effaaed87bc7/server.lua) registers `qb-diving:server:CallCops`, `SellCorals`, `TakeCoral` and `removeItemAfterFill`; it also creates `qb-diving:server:GetDivingConfig` as a QBCore callback.

**This resource registers no standalone `StartDiving`, `CreateDivingSpot` or `GetOxygenLevel` exports** in the reviewed revision. Event names are internal to the source; item payouts must validate inventory, coral availability and the player's allowed interaction location server-side.

### Inventory and sale flow

The official server removes sold coral with `qb-inventory:RemoveItem` and awards coral using `qb-inventory:AddItem`. That means a different inventory fork may require an integration adapter. Use [qb-inventory](/docs/resources/qb-inventory) to confirm method signatures, then validate rewards and sale prices against server-owned data.

## Troubleshooting

| Symptom | First check |
| --- | --- |
| Diving equipment unusable | Shared item names, usable-item handler and inventory |
| Coral never appears | `Config.CoralLocations` and `qb-diving:client:NewLocations` |
| Oxygen never resets | `diving_fill` item, `SetOxygenLevel` and client console |
| Sales fail | Correct sale location, coral item names and inventory API |
| Police notifications missing | `CopsChance` and registered alert event |
| No such export `StartDiving` | No such export in current upstream |

## Update checklist

1. Pin `qb-diving`, `qb-core`, `qb-inventory` and interaction dependencies.
2. Test underwater gear, coral pickup, sale, inventory full and reconnect.
3. Verify server-side limits against repeated or forged coral collection/sale requests.
4. Reconcile local item/config modifications before replacing source.

## Sources

[Repository](https://github.com/qbcore-fivem/qb-diving/tree/6447b72e56552a4e11a3bcd79631effaaed87bc7) · [Config](https://github.com/qbcore-fivem/qb-diving/blob/6447b72e56552a4e11a3bcd79631effaaed87bc7/config.lua) · [Client](https://github.com/qbcore-fivem/qb-diving/blob/6447b72e56552a4e11a3bcd79631effaaed87bc7/client.lua) · [Server](https://github.com/qbcore-fivem/qb-diving/blob/6447b72e56552a4e11a3bcd79631effaaed87bc7/server.lua)
