FiveM Metal Detector

You decide how much to pay.

FiveM Metal Detector Script [Any Framework]

Package Description

# FiveM Metal Detector Script

- USES FIVEM ESCROW ENCRYPTION

## GAME BUILD >= 2699 REQUIRED

- set sv_enforceGameBuild 2699 # the criminal enterprises dlc

You are able to customize the config and the handling of framework scripts in custom.lua

- This has been tested on the latest QBCore and ESX as of 11/9/23

- Preview: https://youtu.be/vFOSVxQK5Cg

# Over 100 locations across the map (beaches and mountains)

## Or create your own

```

Config.Locations = {

    [1] = {

        ["coords"] = vector3(-1711.87, -1030.02, 3.82), -- Set any coords you want

        ["isActive"] = false, -- DONT TOUCH

        ["loot"] = "beach-common" -- Select which group you want from the LootTable

    },

)

```

# Define your own loot tables

### Items must be created in your framework

```

Config.LootTable = {

    ["beach-common"]    = {'sandwich', 'water_bottle', 'bandage', 'fitbit'},

    ["beach-uncommon"]  = {'lockpick', 'joint', 'beer'},

    ["beach-rare"]      = {'weapon_pistol', 'diamond_ring'},

    ["forest-common"]   = {'weapon_wrench', 'sandwich', 'water_bottle'},

    ["forest-uncommon"] = {'vodka', 'cigs', 'advancedlockpick'},

    ["forest-rare"]     = {'phone', 'rolex', 'goldchain'},

    ["ultra-rare"]      = {'weapon_pumpshotgun', 'coke_brick', 'weapon_smg'}

}

```

### Translation compatible

```

Config.Translations = {

    ['pickup'] = 'Press ~INPUT_CONTEXT~ to dig up the treasure',

    ['find-item'] = 'You found a %s',

    ['find-money'] = 'You found $%s'

}

```

### Example of creating the item in QBCore shared/items.lua

    ['weapon_metaldetector']            = {['name'] = 'weapon_metaldetector',              ['label'] = 'Metal Detector',            ['weight'] = 1000,         ['type'] = 'weapon',     ['ammotype'] = nil,                        ['image'] = 'WEAPON_METALDETECTOR.png',      ['unique'] = true,         ['useable'] = true,      ['description'] = 'Metal Detector'},


# Option to add a chance to find money instead of an item

```

Config.ChanceForMoney = 20

Config.MinMoney = 1

Config.MaxMoney = 10000

```

# Customize your Framework's behavior

## custom.lua

```

local Framework

if Config.Framework == 'QBCore' then

    Framework = exports['qb-core']:GetCoreObject()

elseif Config.Framework == 'ESX' then

    TriggerEvent('esx:getSharedObject', function(obj) Framework = obj end)

else

    -- Do something else for whatever framework you have

end

function RewardPlayer(src, item, money)

    if Config.Framework == 'QBCore' then

        local Player = Framework.Functions.GetPlayer(src)

        if item then

            Player.Functions.AddItem(item, 1)

            -- CHANGE THIS TO WHATEVER NOTIFICATION SCRIPT YOU USE

            TriggerClientEvent('QBCore:Notify', src, 'You found a ' .. Framework.Shared.Items[item].label)

        elseif money then

            Player.Functions.AddMoney('cash', money)

            -- CHANGE THIS TO WHATEVER NOTIFICATION SCRIPT YOU USE

            TriggerClientEvent('QBCore:Notify', src, 'You found $' .. money)

        end

    elseif Config.Framework == 'ESX' then

        local xPlayer = Framework.GetPlayerFromId(src)

        if item then

            xPlayer.addInventoryItem(item, 1)

            -- CHANGE THIS TO WHATEVER NOTIFICATION SCRIPT YOU USE

            TriggerClientEvent('ESX:Notify', src, 'You found a '.. item)

        else

            xPlayer.addMoney(money)

            -- CHANGE THIS TO WHATEVER NOTIFICATION SCRIPT YOU USE

            TriggerClientEvent('ESX:Notify', src, 'You found $' .. money)

        end

    else

        -- Do something else if you're not using QB or ESX

    end

end

```