Studios
Loot Boxhouse-3.jpg

Adding Crates

FreeLoot BoxQBCore · Qbox · ESX
PAGE 07 OF 07  ·  COMMANDS & EXPORTS → ADDING CRATESdocs.glitchstudios.dev
Browse docs

Add an entry to config.lootBoxes in config/crates.lua. The key is the crate's item name, and it must match the item you added to your inventory.

Example crate#

cache_street = {
    name = 'Street Stash',
    category = 'Street cache',
    description = 'A sealed bag from a back room.',
    accent = '#5e98d9',
    rewards = {
        { item = 'bandage',  label = 'Bandages', min = 2, max = 4, rarity = 'common',   chance = 34 },
        { item = 'lockpick', label = 'Lockpick', min = 1, max = 3, rarity = 'uncommon', chance = 30 },
        { item = 'radio',    label = 'Radio',    min = 1, max = 1, rarity = 'rare',     chance = 18 },
        { item = 'money',    label = 'Cash',     min = 500, max = 1500, rarity = 'very-rare', chance = 14 },
        { item = 'armour',   label = 'Body Armour', min = 1, max = 1, rarity = 'epic', chance = 4 },
    },
    bonusItems = {
        { item = 'water', amount = 1, label = 'Water' },
    },
},

How rolls work#

  • The crate is taken and the reward is rolled on the server when the player presses Unlock. The roll is saved to the resource KVP store first.
  • The reward goes into the inventory at the reveal, so the inventory popup does not spoil it. A rolled crate pays out exactly once. If the reveal never reports back, the server pays out anyway after revealGrace.
  • Before a crate is taken the player must have room for every possible reward. Anything that still does not fit is dropped at their feet through ox_inventory, or kept for the next login when a drop is not possible.
  • Closing the preview costs nothing. A spinning crate can only be skipped.
  • Open Another only works for the crate that just finished.
  • Nothing runs on the client while the screen is closed.

Heist caches#

Field What it does
blueprint A glitch-crafting recipe id. The reward becomes a crafting blueprint item. Left out of the roll and the preview while glitch-crafting is not running.
unlock The same, for a glitch-crafting unlock id.
sources { jobId = true }. The reward only exists in crates whose metadata source is one of these jobs.
weights { jobId = 2.0 }. Multiplies the reward's chance for crates from that job.