Add a crate#
Add an entry to config.lootBoxes in config/crates.lua, add the crate item to ox_inventory, restart ox_inventory and then glitch-lootBox.
config.lootBoxes = {
ammocratet1 = {
name = 'Ammo Crate T1',
category = 'Supply crate',
description = 'Taped shut. Open it to see what is inside.',
accent = '#b0c3d9',
rewards = {
{ item = 'ammo-9', label = '9mm Ammo', min = 50, max = 150, rarity = 'common', chance = 60 },
{ item = 'ammo-shotgun', label = 'Shotgun Shells', min = 15, max = 35, rarity = 'rare', chance = 30 },
{ item = 'lockpick', min = 1, max = 3, rarity = 'epic', chance = 10 },
},
bonusItems = {
{ item = 'money', amount = { min = 25, max = 100 }, label = 'Cash Find' },
},
},
}
-- ox_inventory/data/items.lua
['ammocratet1'] = { label = 'Ammo Crate T1', weight = 2000, stack = true, close = true },
Give a test player the crate through your inventory admin tools and use it. Check the preview, the unlock, the reveal, the bonus items and Open Another. Closing the preview should not consume the crate.
Hide a chase item#
Give the grade mystery = true. Every reward on that grade shows as a gold star card until the reveal.
config.rarities.epic.mystery = true
Job-specific rewards#
A crate item can carry metadata source set to a job id, for example from a heist script that hands out caches. Rewards with sources only exist in crates from those jobs, and weights scale the chance.
rewards = {
{ item = 'lockpick', min = 1, max = 2, rarity = 'common', chance = 60 },
{ item = 'radio', min = 1, max = 1, rarity = 'rare', chance = 30,
weights = { police = 0.2, gang = 2.0 } },
{ item = 'armour', min = 1, max = 1, rarity = 'epic', chance = 10,
sources = { gang = true } },
},
A crate without a source never rolls a reward that has sources. If every reward in a crate has sources, that crate cannot be opened without a source and the server warns at start.
Skip the screen#
config.useUI = false
Crates open at once, pay out immediately and show a notification.
Add a language#
Copy locales/en.lua, translate the values and set config.locale to the new file name. Keys starting with ui_ are sent to the crate screen.
Read the odds from another script#
-- server side
local rates = exports['glitch-lootBox']:GetDropRates()
print(('lockpick: best chance %.1f%%'):format(rates.lockpick or 0))
local hidden = exports['glitch-lootBox']:GetMysteryItems()
for _, name in ipairs(hidden) do print('hidden behind a mystery grade:', name) end