☰ All guides
ESXQB-Core

6-case

Case opening like in CS: unlimited cases, six rarity grades, items, weapons, money and vehicles as rewards.

Resource folder

six_case

01Requirements

  • ESX (1.1, 1.2 or Legacy) or QB-Core
  • oxmysql or mysql-async. The manifest loads @mysql-async/lib/MySQL.lua, which oxmysql provides as well.
  • An inventory whose item icons are PNG files.

02Installation

  1. 01Sign in to the Cfx Portal with the account you bought with and download the script under Granted Assets.
  2. 02Unzip the download and move the folder six_case into the resources folder of your server. Keep the folder name and upload every file, including the hidden .fxap.
  3. 03Create one item per case. The item name is the key in Config.Casesystem, by default case.
  4. 04Open config.lua, set Config.framework and point Config.PathInventory to the icon folder of your inventory.
  5. 05For Discord logs: open config_server.lua, enter your own webhook link and set enable = true.
  6. 06Add ensure six_case to your server.cfg, below your framework and oxmysql.
  7. 07Restart the server (or run refresh and then ensure with the folder name in the server console).
ESX
INSERT INTO items (name, label) VALUES ('case', 'Case');
qb-core/shared/items.lua
case = { name = 'case', label = 'Case', weight = 100, type = 'item', image = 'case.png', unique = false, useable = true, shouldClose = true, description = 'Open it and see what you get' },

Good to know

ox_inventory: items are not read from the database. Add the item to ox_inventory/data/items.lua instead: ['case'] = { label = 'Case', weight = 100 },

03How it works

A player uses the case item. The opening animation runs, the script first rolls a grade by winrate and then picks a random reward from that grade. One case is removed per opening.

04Configuration

Option

Config.framework
"esx" or "qb".
Config.newESX
true for ESX Legacy (1.2 and newer, shared object via export). false for old ESX 1.1 (shared object via event). Ignored on QB.
Config.Language
"en" or "de" (texts of the Discord log).
Config.PathInventory
NUI path to your inventory icons, for example nui://ox_inventory/web/images/. The picture shown for a reward is item_name + .png from that folder.
Config.Casesystem
One block per case. The key is the item name. Copy the block to add more cases.
winrate
Chance per grade in percent. The six values must add up to 100.
caseitems
Rewards per grade. Every entry has type, item_name, count and label.

Reward type

item
item_name is the item, count the amount.
weapon
item_name is the weapon name, for example weapon_pistol50.
money
item_name is the account (money, bank, black_money), count the amount.
car
item_name is the spawn name. The vehicle is written to owned_vehicles (ESX) or player_vehicles (QB) with a new plate.
›config.luaComplete file · 83 lines
config.lua
Config = {}

Config.framework = "esx" -- esx or qb
Config.newESX = true

Config.Language = "en"

-- Enter here your inventory icon path
Config.PathInventory = "nui://inventory/web/assets/icons/" -- supports only png pictures

Config.Casesystem = {
    ["case"] = { -- Case item name

        winrate = {
            {grade = "Industrial", rate = 40.0}, -- 40% chance
            {grade = "Mil-Spec", rate = 40.0}, -- 40% chance
            {grade = "Restricted", rate = 16.0}, -- 16% chance
            {grade = "Classified", rate = 3.05}, -- 3.05% chance
            {grade = "Covert", rate = 0.85}, -- 0.85% chance
            {grade = "Extraordinary", rate = 0.1} -- 0.1% chance (It's enought and player will hit it, but they need patient)
        },

        caseitems = {
            -- types: item, weapon, money
            ["Industrial"] = {
                {type = "item", item_name = "sandwich", count = 1, label = "sandwich"},
                {type = "weapon", item_name = "weapon_pistol50", count = 1, label = "Pistol .50"},
                {type = "car", item_name = "t20", count = 1, label = "T20"},
                {type = "money", item_name = "bank", count = 20000, label = "20k Money"},
            },

            ["Mil-Spec"] = {
                {type = "item", item_name = "sandwich", count = 1, label = "sandwich"},
                {type = "weapon", item_name = "weapon_pistol50", count = 1, label = "Pistol .50"},
                {type = "car", item_name = "t20", count = 1, label = "T20"},
                {type = "money", item_name = "bank", count = 20000, label = "20k Money"},
            },

            ["Restricted"] = {
                {type = "item", item_name = "sandwich", count = 1, label = "sandwich"},
                {type = "weapon", item_name = "weapon_pistol50", count = 1, label = "Pistol .50"},
                {type = "car", item_name = "t20", count = 1, label = "T20"},
                {type = "money", item_name = "bank", count = 20000, label = "20k Money"},
            },

            ["Classified"] = {
                {type = "item", item_name = "sandwich", count = 1, label = "sandwich"},
                {type = "weapon", item_name = "weapon_pistol50", count = 1, label = "Pistol .50"},
                {type = "car", item_name = "t20", count = 1, label = "T20"},
                {type = "money", item_name = "bank", count = 20000, label = "20k Money"},
            },

            ["Covert"] = {
                {type = "item", item_name = "sandwich", count = 1, label = "sandwich"},
                {type = "weapon", item_name = "weapon_pistol50", count = 1, label = "Pistol .50"},
                {type = "car", item_name = "t20", count = 1, label = "T20"},
                {type = "money", item_name = "bank", count = 20000, label = "20k Money"},
            },

            ["Extraordinary"] = {
                {type = "item", item_name = "sandwich", count = 1, label = "sandwich"},
                {type = "weapon", item_name = "weapon_pistol50", count = 1, label = "Pistol .50"},
                {type = "car", item_name = "t20", count = 1, label = "T20"},
                {type = "money", item_name = "bank", count = 20000, label = "20k Money"},
            },

        }
    },
    -- ADD HERE unlimited Cases
}

Config.Locales = {
    ['en'] = {
        -- Discord Logs
        ["discord_title"] = "Case Logs",
        ["discord_sellmessage"] = "Player %s has pulled the item: %s (%s) Quantity: %s from the Case: **%s**.",
    },
    ['de'] = {
        -- Discord Logs
        ["discord_title"] = "Case Logs",
        ["discord_sellmessage"] = "Der Spieler %s hat das Item: **%s** (%s) Anzahl: **%s** aus dem Case: **%s** gezogen.",
    },
}
›config_server.luaComplete file · 16 lines
config_server.lua
Server_Config = {}

Server_Config.WebhookSettings = {
    color = 159900,
    name = "SIX-CASE",
    icon_url = "https://i.imgur.com/JFU0rBJ.png",
    author_url = "https://i.imgur.com/JFU0rBJ.png",
    server_name = "6-services"
}

Server_Config.Webhooks = {
    ['reward_case'] = {
        link = "https://discord.com/api/webhooks/...",
        enable = true
    },
}

Careful

Older downloads have a foreign webhook link in config_server.lua with enable = true. Replace it with your own link or set enable = false, otherwise your case logs do not arrive in your own Discord.

05Troubleshooting

Rewards show without a picture.

Config.PathInventory is wrong or the icon is not a PNG named exactly like item_name.

The case item cannot be used.

The item name must match the key in Config.Casesystem exactly, including upper and lower case.

06Still stuck?

Open a ticket on our Discord. Send the script name, your framework and version, and the full error from the server console (F8 for client errors). That saves a round of questions.