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, and Qbox out of the box
  • 📦 Multiple inventory support - Works with ox_inventory, qb-inventory, and ESX inventory
  • 🎁 Metadata support - Items can include custom metadata
  • 📝 Config + Runtime API - Define lootboxes in config or register them dynamically via exports

Dependencies

Installation

Download the Resource

Download or clone the repository from GitHub.

git clone https://github.com/Sleepless-Development/sleepless_lootbox.git

Build the UI

Navigate to the web folder and build the React UI:

cd sleepless_lootbox/web
npm install
npm 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 and your framework):

ensure ox_lib
ensure sleepless_lootbox

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: