metal detecting
Requirements, install steps, items and first start for metal detecting, a FiveM script where players sweep the beach with one of five detectors, dig up what they find and sell it.
metal detecting (lation_detecting) sends players to the beach with a metal detector. They walk the sand until a find turns up nearby, follow the beeps and the distance to the spot, and dig it up with a shovel. Five detectors unlock as players level up, each reaching farther and turning up valuable finds more often, and everything they dig up sells at the sell shop. It is set up in config.lua, and every line players read is in strings.lua.
Works on Qbox, QBCore and ESX.
Requirements
| Resource | Needed | What for |
|---|---|---|
oxmysql | Required | Each player's level, XP and stats |
ox_lib | Required | Callbacks and shop zones, and the default menus, dialogs, notifications and text prompts |
qbx_core, qb-core or es_extended | Required | Players, jobs, money and usable items |
| An inventory | Required on Qbox and ESX | ox_inventory, qb-inventory, qs-inventory, ps-inventory, origen_inventory or codem-inventory. On QBCore, qb-core's own items work too. |
ox_target, qb-target or interact | Optional | Shopkeepers open with a key prompt by default. Set Config.Setup.interact to target them instead. lation interact works as ox_target or qb-target. |
lation_ui | Optional | Menus, dialogs and notifications in the lation ui look, once you pick it in Config.Setup. The text prompts follow when you pick it in client/functions.lua (text prompts). |
okokNotify, sd-notify or wasabi_notify | Optional | Other notification systems |
jg-textui or okokTextUI | Optional | Other text prompt systems |
fmsdk or fm-logs | Optional | Logging to Fivemanage or Fivemerr |
oxmysql and ox_lib are dependencies in fxmanifest.lua: metal detecting doesn't start without them. The framework and inventory are detected when it starts. The interaction, notification, menu and dialog systems are set in Config.Setup.
Install
Follow the install guide, then:
Keep the folder name lation_detecting. The script calls its own exports by that name, its menus load their pictures from it and the update check looks it up, and a renamed folder prints an error on start and again every 15 minutes.
Add the 52 items and their images to your inventory. The files ship in install/, and the image names match the item names.
Paste the contents of install/items/ox_inventory.txt into ox_inventory/data/items.lua, then copy every file in install/images/ into ox_inventory/web/images/. This is the one to use on Qbox.
Paste the contents of install/items/qb-inventory.txt into qb-core/shared/items.lua, then copy every file in install/images/ into qb-inventory/html/images/.
Paste the contents of install/items/qs-inventory.txt into the item list of qs-inventory, then copy every file in install/images/ into its image folder.
Add the same 52 items in your inventory's own format, with the labels and weights in items below, and copy every file in install/images/ into its image folder. The detectors are made usable through your framework, so nothing else is needed for them.
Leave the install folder where it is. On every start the script reads install/lation_detecting.sql to create its table, and the shop menus show the pictures in install/images/.
Ensure it after its dependencies, your framework and your inventory. If you run lation ui, it goes first, above ox_lib, because the lation ox_lib fork looks for it when ox_lib starts.
ensure lation_ui # optional
ensure oxmysql
ensure ox_lib
ensure qbx_core # or qb-core / es_extended
ensure ox_target # optional: or lation_interact / qb-target / interact
ensure ox_inventory # your inventory
ensure lation_detectingLook over config.lua. As it ships, shopkeepers open with a key prompt, and menus, dialogs and notifications use ox_lib. See configuration.
Restart the server.
There is no SQL to import. On every start metal detecting runs install/lation_detecting.sql, which creates the lation_detecting table when it is missing, with one row per player:
| Column | Holds |
|---|---|
identifier | The player's ESX identifier, or their citizenid on Qbox and QBCore |
level | Their level, 1 to 5 |
experience | Their total XP, which stops at 100,000 |
items_found | How many items they've dug up |
money_earned | How much the sell shop has paid them |
A player's row is made at level 1 the first time the script looks them up, and kept in memory while they play. It is saved when they leave, when the resource stops and when txAdmin shuts the server down.
Nothing is saved on a timer, so a server crash loses the XP and stats players earned since their last save.
Upgrading from version 1
Version 1 kept levels in a table named metal_detecting. To carry them over, run install/rename_table.sql on your database once, before version 2 starts for the first time. It renames the table to lation_detecting and its player_identifier column to identifier.
If version 2 has already started, it has made its own lation_detecting table and the rename fails. Drop that new table (it only holds what was earned since), run the file, then restart. A server that never ran version 1 doesn't need the file.
What ships with it
stream/holds the five detector props, one color each, and the.ytypthat loads them. They stream with the resource, so there is nothing to install.install/holds the item files, the 52 item images and the SQL file.config.lua,strings.lua,logs.lua, the two files inbridge/,client/functions.luaandserver/functions.luaship open for you to edit. See open files.
Items
| Item | Label | Weight | Usable |
|---|---|---|---|
blue_metaldetector | Beginner's Beacon | 475 | Yes, takes out or puts away the detector |
green_metaldetector | Lustrous Locator | 475 | Yes |
red_metaldetector | Treasure Trove Tracker | 475 | Yes |
orange_metaldetector | Goldseeker's Grail | 475 | Yes |
black_metaldetector | Archaeo Ace | 475 | Yes |
md_shovel | Shovel | 55 | No, it only has to be carried |
46 finds, md_bottlecap to md_presidentialwatch | See finds | 25 each | No |
Players dig with a key at the spot, not by using the shovel, even though the qb-inventory and qs-inventory files mark it usable.
The qb-inventory and qs-inventory files label five finds differently from the ox_inventory file: md_screw is Rusty Screw, md_blackwatch is Black Watch, and md_diamondearings, md_goldearings and md_silverearings are spelled Earrings. The sell shop shows whichever label your inventory has.
First start
The lation_detecting table is created, and two shopkeepers appear: the detector shop on Vespucci Beach, under the Metal Detectors blip, and the sell shop outside a pawn shop in Downtown Vinewood, under the Detectors Sell Shop blip.
Buy the Beginner's Beacon at the detector shop for $2,750, and a shovel under Buy Shovel at the sell shop for $250. Both take cash.
Use the detector from your inventory on the beach and start walking. See detecting.
Commands
| Command | Who | What it does |
|---|---|---|
/metaldetecting | Everyone | Opens the player's stats: their level, progress to the next one, items found and money earned. Renamed with Config.Setup.command. |
/simulate | Everyone, while Config.Setup.debug is on | /simulate 1 500 rolls 500 finds on the first detector's loot table and prints how many of each item came up in the F8 console. See loot tables. |
There are no admin commands or permissions.
Troubleshooting
The console says to rename the folder
The resource folder isn't named lation_detecting. Rename it back and restart; the message repeats every 15 minutes until you do.
The console keeps saying install folder or .sql files missing
install/lation_detecting.sql isn't in the resource folder, so the table can't be created. Put the install folder back from the download and restart. The message repeats every 10 seconds until you do.
The prompt says Error
The player is standing still, running, or not on beach sand. Nothing counts until they walk on sand again. Running counts only with Config.Detecting.running on, and other ground only once you add it: see where players can detect.
Using the shovel from the inventory does nothing
Digging starts with E at the spot, when the prompt says E - Start Digging. The shovel only has to be in the player's inventory.
A player can't buy or use a detector
Each detector needs its level: the Lustrous Locator needs level 2, and so on. /metaldetecting shows the player's level. To let anyone use any detector, set Config.Detecting.verify_level to false.
SQL error: metal_detecting doesn't exist
install/rename_table.sql was run on a server that never had version 1. Nothing needs fixing; that file is only for upgrades.
The F8 console says No interaction system defined in the config file
Config.Setup.interact isn't one of textui, ox_target, qb-target, interact or custom. Set one of them and restart.
The console says Unable to fetch version information from API
The update check couldn't reach the version server. It changes nothing in game. Set Config.Setup.version to false to skip it.
Still stuck? Ask in our Discord: the people who write the scripts answer.
Last updated