Lootbox

Sleepless Lootbox

A CS:GO-style lootbox/case opening system for FiveM with a polished React UI, weight-based loot pools, and framework-agnostic design.

Features

  • 🎰 CS:GO-style roller animation - Smooth spinning animation
  • ⚖️ Weight-based loot system - Uses ox_lib selector for flexible drop rates
  • 👀 Preview system - Players can view case contents and drop chances before opening
  • 🎨 Rarity system - Visual rarity tiers (Common, Uncommon, Rare, Epic, Legendary)
  • 🔧 Framework agnostic - Supports ESX, QBCore, Qbox, and ox_core out of the box
  • 📦 Multiple inventory support - Works with ox_inventory, qb-inventoryy
  • 🎁 Metadata support - Items can include custom metadata
  • 📝 Config + Runtime API - Define lootboxes in config or register them dynamically via exports
  • 🎀 Bonus items - Award hidden bonus items alongside the main reward (e.g., ammo with weapons)
  • 🔌 Custom reward hooks - Extensible hook system for custom reward types (vehicles, bank money, etc.)

Dependencies

  • ox_lib (opens in a new tab) (required)
  • A supported framework (ESX, QBCore, Qbox, or ox_core)
  • A supported inventory system (ox_inventory, qb-inventory)

Installation

Download the Resource

Download the latest release from GitHub Releases (opens in a new tab). The release comes pre-built and ready to use.

If you want to build from source instead, clone the repository and run the following in the web folder using bun (opens in a new tab):

bun install
bun run build

Add to Server

Place the sleepless_lootbox folder in your server's resources directory.

Configure Your Server

Add the following to your server.cfg (after ox_lib, your framework, and your inventory):

ensure ox_lib
ensure es_extended  # or qb-core, qbx_core, ox_core
ensure ox_inventory # or qb-inventory
ensure sleepless_lootbox

Configure Framework Items

Depending on your framework, you may need to configure your item definitions. See the Framework Setup page for details.

Configure Lootboxes

Edit config.lua to define your lootboxes and customize settings. See the Configuration page for details.

Quick Start

Basic Lootbox Definition

config.lootboxes = {
    ['gun_case'] = {
        label = 'Gun Case',
        description = 'Contains various firearms',
        items = {
            -- Format: { weight, { name, amount, metadata?, rarity? } }
            { 80, { name = 'WEAPON_PISTOL', amount = 1 } },
            { 15, { name = 'WEAPON_SMG', amount = 1 } },
            { 4, { name = 'WEAPON_RIFLE', amount = 1 } },
            { 1, { name = 'WEAPON_RPG', amount = 1 } },
        },
    },
}

Weight System

Weights determine the relative drop chance of each item:

  • Higher weight = more common drops
  • Example: Items with weights 80, 15, 4, 1 (total 100) have 80%, 15%, 4%, and 1% chances respectively

Weights don't need to add up to 100 - they're calculated relative to the total weight of all items in the lootbox.

Rarity Auto-Calculation

If you don't specify a rarity on an item, it's automatically calculated based on the weight:

RarityWeight Threshold
Commonweight >= 17
Uncommonweight >= 4
Rareweight >= 1
Epicweight >= 0.3
Legendaryweight < 0.3

You can customize these thresholds in config.lua.

Debug Commands

When config.debug = true, the following commands are available:

CommandDescription
/lootbox_test [caseName]Test open a case without removing the item
/lootbox_preview [caseName]Print preview data to console
/lootbox_listList all registered lootboxes
/lootbox_test_uiTest the UI with dummy data (client)
/lootbox_test_previewTest the preview UI with dummy data (client)

Support

If you need help or have questions: