NX Dumpster Diving

Loot & Items

How the weighted loot table works and how to add your own items.

How loot works

When a player finishes searching a dumpster:

  1. There's an emptyChance (default 30%) that they find nothing.
  2. Otherwise the loot table is rolled between rolls.min and rolls.max times (default 1 or 2).
  3. Each roll picks one item based on its chance weight and gives a random amount between its min and max.

The loot table

config.lua
Config.Loot = {
    -- Junk
    { item = 'crushed_can',   chance = 30, min = 1, max = 4 },
    { item = 'empty_chips',   chance = 25, min = 1, max = 3 },
    { item = 'trash_bag',     chance = 20, min = 1, max = 2 },
    { item = 'moldy_bread',   chance = 18, min = 1, max = 2 },
    { item = 'rotten_burger', chance = 15, min = 1, max = 1 },
    { item = 'dirty_panties', chance = 8,  min = 1, max = 1 },
    -- Valuables
    { item = 'stud_earring',  chance = 6,  min = 1, max = 2 },
    { item = 'gold_hoops',    chance = 4,  min = 1, max = 1 },
    { item = 'ak_pendant',    chance = 3,  min = 1, max = 1 },
    { item = 'gold_watch',    chance = 3,  min = 1, max = 1 },
    { item = 'hex_watch',     chance = 2,  min = 1, max = 1 },
    { item = 'gold_ingot',    chance = 1,  min = 1, max = 1 },
    { item = 'gold_bar',      chance = 1,  min = 1, max = 1 },
    { item = 'diamond',       chance = 1,  min = 1, max = 1 },
}
itemstring
The ox_inventory item name.
chancenumber
A weight, not a percentage. Higher means more common. An item with 30 is 30 times more likely than one with 1.
min / maxnumber
How many of the item are given when it's picked.

Understanding weights

An item's chance per roll is its weight divided by the total of all weights. With the defaults the weights add up to 137, so a diamond (weight 1) has a 1 in 137 chance per roll, and a crushed can (weight 30) has a 30 in 137 chance.

ItemWeightPer rollPer search
Crushed Can (crushed_can)3021.9%1 in 5
Empty Chip Bag (empty_chips)2518.2%1 in 6
Bag of Trash (trash_bag)2014.6%1 in 7
Moldy Bread (moldy_bread)1813.1%1 in 8
Rotten Burger (rotten_burger)1510.9%1 in 9
Dirty Panties (dirty_panties)85.8%1 in 17
Stud Earring (stud_earring)64.4%1 in 22
Gold Hoop Earrings (gold_hoops)42.9%1 in 33
AK Pendant (ak_pendant)32.2%1 in 44
Gold Watch (gold_watch)32.2%1 in 44
Hex Watch (hex_watch)21.5%1 in 66
Gold Ingot (gold_ingot)10.7%1 in 131
Gold Bar (gold_bar)10.7%1 in 131
Diamond (diamond)10.7%1 in 131

"Per search" takes the empty chance and the 1–2 rolls into account. With the defaults, about 15% of searches find at least one valuable.

Balancing tips

  • To make one item rarer, lower its weight. The others become slightly more common.
  • To make everything rarer, raise emptyChance or lower rolls.max.
  • Check the pawn prices afterwards so rare items are worth the effort.

Adding your own items

  1. Create the item in ox_inventory

    ox_inventory/data/items.lua
    ['old_phone'] = {
        label = 'Old Phone',
        weight = 200,
        stack = true,
        close = true,
        description = 'A cracked phone. Might still be worth something.',
    },

    Add an image called old_phone.png to ox_inventory/web/images/.

  2. Add it to the loot table

    config.lua
    { item = 'old_phone', chance = 5, min = 1, max = 1 },
  3. Give it a price (optional)

    If the junk buyer should take it, add it to the prices:

    config.lua
    Config.Pawn = {
        prices = {
            -- ...
            old_phone = 120,
        },
    }
  4. Restart the server

    Restart so ox_inventory picks up the new item.

You can put any item in the loot table, including items from other scripts. They don't need to be sellable at the junk buyer.