> For the complete documentation index, see [llms.txt](https://alt0.gitbook.io/alt0-docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://alt0.gitbook.io/alt0-docs/alt0-metal-detecting/installation.md).

# Installation

## Requirements

| Resource                                          | Notes                                                                                                                                                      |
| ------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------- |
| A framework                                       | Qbox (`qbx_core`), QBCore (`qb-core`) or ESX (`es_extended`). Found automatically, or set `Config.Framework`                                               |
| An inventory                                      | [ox\_inventory](https://github.com/overextended/ox_inventory) or qb-inventory 2.x. Found automatically, or set `Config.Inventory`. ESX needs ox\_inventory |
| [ox\_lib](https://github.com/overextended/ox_lib) | Required                                                                                                                                                   |

## 1. Add the resource

```cfg
ensure ox_lib
ensure ox_inventory     # or qb-inventory
ensure qbx_core         # or qb-core / es_extended
ensure alt0-metaldetecting
```

The resource is protected by Cfx.re Asset Escrow and only starts on the account that downloaded it. See [Installing a script](/alt0-docs/getting-started/installing.md).

## 2. Items

The detector and everything that can be found are items your inventory has to know. Loot your inventory does not have is never found (the console lists it at start), so you can also remove entries from `config/loot.lua` instead.

Pictures for all of them are in the resource's `items/` folder (128x128 PNG). Copy them to `ox_inventory/web/images/` or `qb-inventory/html/images/`.

**ox\_inventory**, add to `ox_inventory/data/items.lua`:

```lua
['metaldetector'] = {
    label = 'Metal Detector', weight = 1500, stack = false, close = true,
    client = { event = 'alt0-metaldetecting:client:toggle' },
},
['aluminum_can'] = { label = 'Crushed Soda Can', weight = 100, stack = true, close = false },
['screw'] = { label = 'Screws & Fasteners', weight = 100, stack = true, close = false },
['metalscrap'] = { label = 'Scrap Metal', weight = 100, stack = true, close = false },
['plastic_bottle'] = { label = 'Crushed Plastic Bottle', weight = 100, stack = true, close = false },
['rusty_nail'] = { label = 'Rusty Iron Spike', weight = 100, stack = true, close = false },
['copper_wire'] = { label = 'Tattered Copper Wire', weight = 100, stack = true, close = false },
['rubber_scrap'] = { label = 'Discarded Rubber Scrap', weight = 100, stack = true, close = false },
['electric_scrap'] = { label = 'Electronic Scrap', weight = 100, stack = true, close = false },
['copper_pipe'] = { label = 'Corroded Copper Pipe', weight = 100, stack = true, close = false },
['lead_sinker'] = { label = 'Lost Fishing Sinker', weight = 100, stack = true, close = false },
['broken_phone'] = { label = 'Waterlogged Cellphone', weight = 100, stack = true, close = false },
['broken_radio'] = { label = 'Waterlogged Radio', weight = 100, stack = true, close = false },
['fossil'] = { label = 'Ancient Megalodon Tooth', weight = 100, stack = true, close = false },
['spanish_doubloon'] = { label = '1715 Spanish Gold Doubloon', weight = 100, stack = true, close = false },
['silver_ingot'] = { label = 'Tarnished Silver Ingot', weight = 100, stack = true, close = false },
['antique_pocketwatch'] = { label = 'Corroded Gold Pocketwatch', weight = 100, stack = true, close = false },
['diamond_ring'] = { label = 'Lost Diamond Ring', weight = 100, stack = true, close = false },
['match_barrel'] = { label = 'Wrapped 9mm Match Barrel', weight = 100, stack = true, close = false },
['bolt_carrier'] = { label = 'Oiled Bolt Carrier Group', weight = 100, stack = true, close = false },
['pistol_frame'] = { label = 'Polymer Pistol Frame', weight = 100, stack = true, close = false },
```

**qb-inventory**, add to `qb-core/shared/items.lua`:

```lua
metaldetector = { name = 'metaldetector', label = 'Metal Detector', weight = 1500, type = 'item', image = 'metaldetector.png', unique = true, useable = true, shouldClose = true, description = 'Sweeps sand for buried metal' },
aluminum_can = { name = 'aluminum_can', label = 'Crushed Soda Can', weight = 100, type = 'item', image = 'aluminum_can.png', unique = false, useable = false, shouldClose = false, description = 'Crushed Soda Can' },
screw = { name = 'screw', label = 'Screws & Fasteners', weight = 100, type = 'item', image = 'screw.png', unique = false, useable = false, shouldClose = false, description = 'Screws & Fasteners' },
metalscrap = { name = 'metalscrap', label = 'Scrap Metal', weight = 100, type = 'item', image = 'metalscrap.png', unique = false, useable = false, shouldClose = false, description = 'Scrap Metal' },
plastic_bottle = { name = 'plastic_bottle', label = 'Crushed Plastic Bottle', weight = 100, type = 'item', image = 'plastic_bottle.png', unique = false, useable = false, shouldClose = false, description = 'Crushed Plastic Bottle' },
rusty_nail = { name = 'rusty_nail', label = 'Rusty Iron Spike', weight = 100, type = 'item', image = 'rusty_nail.png', unique = false, useable = false, shouldClose = false, description = 'Rusty Iron Spike' },
copper_wire = { name = 'copper_wire', label = 'Tattered Copper Wire', weight = 100, type = 'item', image = 'copper_wire.png', unique = false, useable = false, shouldClose = false, description = 'Tattered Copper Wire' },
rubber_scrap = { name = 'rubber_scrap', label = 'Discarded Rubber Scrap', weight = 100, type = 'item', image = 'rubber_scrap.png', unique = false, useable = false, shouldClose = false, description = 'Discarded Rubber Scrap' },
electric_scrap = { name = 'electric_scrap', label = 'Electronic Scrap', weight = 100, type = 'item', image = 'electric_scrap.png', unique = false, useable = false, shouldClose = false, description = 'Electronic Scrap' },
copper_pipe = { name = 'copper_pipe', label = 'Corroded Copper Pipe', weight = 100, type = 'item', image = 'copper_pipe.png', unique = false, useable = false, shouldClose = false, description = 'Corroded Copper Pipe' },
lead_sinker = { name = 'lead_sinker', label = 'Lost Fishing Sinker', weight = 100, type = 'item', image = 'lead_sinker.png', unique = false, useable = false, shouldClose = false, description = 'Lost Fishing Sinker' },
broken_phone = { name = 'broken_phone', label = 'Waterlogged Cellphone', weight = 100, type = 'item', image = 'broken_phone.png', unique = false, useable = false, shouldClose = false, description = 'Waterlogged Cellphone' },
broken_radio = { name = 'broken_radio', label = 'Waterlogged Radio', weight = 100, type = 'item', image = 'broken_radio.png', unique = false, useable = false, shouldClose = false, description = 'Waterlogged Radio' },
fossil = { name = 'fossil', label = 'Ancient Megalodon Tooth', weight = 100, type = 'item', image = 'fossil.png', unique = false, useable = false, shouldClose = false, description = 'Ancient Megalodon Tooth' },
spanish_doubloon = { name = 'spanish_doubloon', label = '1715 Spanish Gold Doubloon', weight = 100, type = 'item', image = 'spanish_doubloon.png', unique = false, useable = false, shouldClose = false, description = '1715 Spanish Gold Doubloon' },
silver_ingot = { name = 'silver_ingot', label = 'Tarnished Silver Ingot', weight = 100, type = 'item', image = 'silver_ingot.png', unique = false, useable = false, shouldClose = false, description = 'Tarnished Silver Ingot' },
antique_pocketwatch = { name = 'antique_pocketwatch', label = 'Corroded Gold Pocketwatch', weight = 100, type = 'item', image = 'antique_pocketwatch.png', unique = false, useable = false, shouldClose = false, description = 'Corroded Gold Pocketwatch' },
diamond_ring = { name = 'diamond_ring', label = 'Lost Diamond Ring', weight = 100, type = 'item', image = 'diamond_ring.png', unique = false, useable = false, shouldClose = false, description = 'Lost Diamond Ring' },
match_barrel = { name = 'match_barrel', label = 'Wrapped 9mm Match Barrel', weight = 100, type = 'item', image = 'match_barrel.png', unique = false, useable = false, shouldClose = false, description = 'Wrapped 9mm Match Barrel' },
bolt_carrier = { name = 'bolt_carrier', label = 'Oiled Bolt Carrier Group', weight = 100, type = 'item', image = 'bolt_carrier.png', unique = false, useable = false, shouldClose = false, description = 'Oiled Bolt Carrier Group' },
pistol_frame = { name = 'pistol_frame', label = 'Polymer Pistol Frame', weight = 100, type = 'item', image = 'pistol_frame.png', unique = false, useable = false, shouldClose = false, description = 'Polymer Pistol Frame' },
```

The detector is used from the inventory: with ox\_inventory through the item's client event above, with qb-inventory through qb-core's usable items (registered automatically).

## 3. How players use it

1. Use the metal detector item to take it out; use it again to put it away.
2. Walk over sand. The signal gets stronger and the beeps faster as you near a hidden spot.
3. Stand on the spot (full signal), press **E**, pass the skill check and dig.

There are no player commands.
