[ESX - QBCore - Custom] Loot Box v2 | Case Opening [KOX-Core]

:receipt: Description :receipt:

KOX_CORE_LOOTBOX_V2 is an innovative and customizable lootbox system, allowing you to create your own unique reward system that perfectly matches the needs of your server.

This script is the perfect complement to any FiveM server, whether you’re using ESX, QBCore or your own framework.

Our script is easy to install and comes with a clean, modern user interface that will impress your players.

:bulb: Features :bulb:

:desktop_computer: Extreme Compatibility

  • Frameworks : ESX, QBCore, Custom

  • Inventories : Aquiver Grid Inventory, Aquiver Inventory v4, OX Inventory, QB Inventory, AXFW’s Inventory, Quasar Inventory or Custom !

  • MySQL : MySQL-Async, OXMysql, GHmattimysql, Ice MySQL

  • Languages : English , French, Spanish, German, Italian, Portuguese, Russe, Dutch, Custom

:art: Optimal Modification

  • Total editing possible (case, category, image, effect, …)
    (PSD files and tutorials are available on our documentation page.)

:white_check_mark: Types of items that can be won :

  • Item
  • Weapon
  • Cash/bank
  • Vehicle of any type (helicopter, plane, boat, motorcycle, car)

:arrow_right_hook: Other Details

  • 3 basic categories (Best Case, Trending Case, Car Box)

  • 9 basic cases

  • Creating/using promo codes (FiveM ACE system role-dependent restricted control.)

  • Quality code

  • Good optimization

  • Security against modders on events

  • OneSync Infinity Ready

  • Easy to install

  • Support included

:gear: Config :gear:

Global Config
Config = {}

------ OTHERS SETTINGS ------
Config.BoutiqueLink = "https://kox-core.tebex.io/"
------ END OTHERS SETTINGS -----

------ FRAMEWORK SETTINGS ------
Config.ESXSettings = {
    enabled = false,
    resourceName = 'es_extended'
}

Config.QBSettings = {
    enabled = true,
    resourceName = 'qb-core'
}

Config.OwnedVehicles = {
    tableSQLName = 'player_vehicles' -- "owned_vehicles" for ESX / "player_vehicles" for QB
}

------ INVENTORY SETTINGS ------
Config.InventoryName =  'qb-inventory' -- If you want to use another inventory, you will have to adapt the code in server/editable/inventory/
-- SUPPORT : Aquiver Grid Inventory (avp_grid_inventory) / Aquiver Inventory v4 (avp_inv_4) / OX Inventory (ox_inventory) / qb-inventory / AXFW’s Inventory (inventory) / Quasar Inventory (qs-inventory)

------ END INVENTORY SETTINGS SETTINGS -------


------ SQL SETTINGS ------
Config.MySQL = {
    apiName = 'oxmysql', -- mysql-async - oxmysqL - ghmattimysql - ice_mysql
    databaseId = 1 -- ONLY ice_mysql : you will have to put the database ID here
}

------ END SQL SETTINGS ------

------ PERMISSIONS SETTINGS ------
-- Check for https://app.gitbook.com/o/ExPfNwiiD16YNWl0UwyK/s/VUCMABp927yVNuDjD4nK/ace-permissions for additional requirements
Config.AllowedGroups = {
    'superadmin', --ESX
    'admin', --ESX
    'god', --QBCore
}

Config.CommandNameCreatePromoCode = 'createPromoCode'

------ END PERMISSIONS SETTINGS ------


------ INTERFACE SETTINGS ------
Config.OpenInterfaceViaCommand = true
Config.OpenInterfaceCommandName = 'lootbox'

-- ALTERNATIVE : TriggerEvent("KOX-Core:LootBox:v2:openUI", true or false) or TriggerClientEvent("KOX-Core:LootBox:v2:openUI", source, true or false)

------ END INTERFACE SETTINGS ------
Rarities Config
const rarities = [
    {
        name: "Common",
        probability: 0.5,
        color: "#FFFFFF",
        glow: "./img/lueur/blanche.png",
    },
    {
        name: "Uncommon",
        probability: 0.3,
        color: "#00FF00",
        glow: "./img/lueur/vert.png",
    },
    {
        name: "Rare",
        probability: 0.1,
        color: "#0000FF",
        glow: "./img/lueur/bleu.png",
    },
    {
        name: "Epic",
        probability: 0.09,
        color: "#8c00ff",
        glow: "./img/lueur/violet.png",
    },
    {
        name: "Legendary",
        probability: 0.01,
        color: "#FF00FF",
        glow: "./img/lueur/rouge.png",
    },
    {
        name: "Mythical",
        probability: 0.001,
        color: "#ff0000",
        glow: "./img/lueur/rouge.png",
    },
];
Categories Config
const categories = [
    {
        name: "Best Case",
        id: "bestCases",
        logo: `<i class="fa-solid fa-tag mx-2" style="color: #00c6ff"></i>`,
    },
    {
        name: "Trending case",
        id: "trendingCases",
        logo: `<i class="fa-solid fa-fire mx-2" style="color: #00c6ff"></i>`,
    },
    {
        name: "Car Box",
        id: "carCases",
        logo: `<i class="fa-solid fa-warehouse mx-2" style="color: #00c6ff"></i>`,
    },
];
Items Config
const items = {
    Money: {
        name: "money",
        label: "Cash",
        imgSrc: "./img/weapons/cash.png",
        isCash: true,
    },

    BankMoney: {
        name: "bank",
        label: "Bank Money",
        imgSrc: "./img/weapons/cash.png",
        isBankMoney: true,
    },

    Medikit: {
        name: "bandage",
        label: "Medikit",
        imgSrc: "./img/weapons/medkit.png",
    },

    Knife: {
        name: "weapon_knife",
        label: "Knife",
        imgSrc: "./img/weapons/knife.png",
        isWeapon: true,
    },

    Pistol: {
        name: "weapon_pistol",
        label: "Pistol",
        imgSrc: "./img/weapons/pistol.png",
        isWeapon: true,
    },

    Molotov: {
        name: "weapon_molotov",
        label: "Molotov",
        imgSrc: "./img/weapons/molotov.png",
        isWeapon: true,
    },

    SMGMkII: {
        name: "weapon_smg_mk2",
        label: "SMG Mk II",
        imgSrc: "./img/weapons/mp5.png",
        isWeapon: true,
    },

    Ak47: {
        name: "weapon_assaultrifle",
        label: "Ak47",
        imgSrc: "./img/weapons/ak47.png",
        isWeapon: true,
    },

    RPG: {
        name: "weapon_rpg",
        label: "RPG",
        imgSrc: "./img/weapons/rpg.png",
        isWeapon: true,
    },

    Kevlar: {
        name: "kevlar",
        label: "Kevlar",
        imgSrc: "./img/weapons/kevlar.png",
    },

    RustyCar: {
        name: "blista",
        label: "Rusty Car",
        imgSrc: "./img/garage/car/rusty_car.png",
        isCar: true,
    },

    RedCar: {
        name: "adder",
        label: "Red Car",
        imgSrc: "./img/garage/car/red_car.png",
        isCar: true,
    },

    GraffityCar: {
        name: "sultan",
        label: "Graffity Car",
        imgSrc: "./img/garage/car/graffity_car.png",
        isCar: true,
    },

    NTRPCar: {
        name: "sultan2",
        label: "NTRP Car",
        imgSrc: "./img/garage/car/newtown_car.png",
        isCar: true,
    },
};
  
Cases Config
const cases = {
    GreenCase: {
        name: 'Green Case',
        price: 100,
        categoryId: "bestCases",
    
        images: [
            {
                src: "./img/box/case/green_case.png",
                class: "test",
            },
            {
                src: "./img/box/items/green_m4.png",
                class: "position-absolute item-in-case",
            },
        ],

        items: {
            Common: [
                {item: items["Knife"], resalePrice: 10, quantity: 1},
                {item: items["Medikit"], resalePrice: 10, quantity: 3},
            ],

            Uncommon: [
                {item: items["Pistol"], resalePrice: 30, quantity: 1},
                {item: items["Molotov"], resalePrice: 30, quantity: 1},
            ],

            Rare: [
                {item: items["SMGMkII"], resalePrice: 60, quantity: 1},
                {item: items["Ak47"], resalePrice: 60, quantity: 1},
            ],

            Legendary: [
                {item: items["RPG"], resalePrice: 120, quantity: 1},
                {item: items["Kevlar"], resalePrice: 120, quantity: 1},
            ],

            Mythical: [
                {item: items["NTRPCar"], resalePrice: 1000, quantity: 1},
                {item: items["GraffityCar"], resalePrice: 1000, quantity: 1},
            ],
        },
    },

    PistolCase: {
        name: "Pistol Case",
        price: "200",
        categoryId: "bestCases",

        images: [
            {
                src: "./img/box/case/purple_case.png",
                class: "test",
            },
            {
                src: "./img/box/items/purple_pistol.png",
                class: "position-absolute item-in-case",
            },
        ],

        items: {
            Common: [
                {item: items["SMGMkII"], resalePrice: 60, quantity: 1}
            ],

            Rare: [
                {item: items["Pistol"], resalePrice: 30, quantity: 1}
            ],

            Epic: [
                {item: items["Ak47"], resalePrice: 60, quantity: 1}
            ],
        },
    },

    graffityCase: {
        name: "Graffity Case",
        price: "800",
        categoryId: "bestCases",

        images: [
            {
                src: "./img/box/case/graffity_case.png",
                class: "test",
            },
            {
                src: "./img/box/items/blue_graffity_mp5.png",
                class: "position-absolute item-in-case",
            },
        ],

        items: {
            Common: [
                {item: items["Knife"], resalePrice: 10, quantity: 1},
                {item: items["Medikit"], resalePrice: 10, quantity: 1},
            ],
            Uncommon: [
                {item: items["Pistol"], resalePrice: 30, quantity: 1},
                {item: items["Molotov"], resalePrice: 30, quantity: 1},
            ],
            Rare: [
                {item: items["SMGMkII"], resalePrice: 60, quantity: 1},
                {item: items["Ak47"], resalePrice: 60, quantity: 1},
            ],
        },
    },

    grassCase: {
        name: "Grass Case",
        price: "200",
        categoryId: "trendingCases",
        
        images: [
            {
                src: "./img/box/case/grass_case.png",
                class: "test",
            },
            {
                src: "./img/box/items/green_grass_ak.png",
                class: "position-absolute item-in-case",
            },
        ],

        items: {
            Common: [
                { item: items["Knife"], resalePrice: 10, quantity: 1 },
                { item: items["Medikit"], resalePrice: 10, quantity: 1 },
            ],
            Uncommon: [
                { item: items["Pistol"], resalePrice: 30, quantity: 1 },
                { item: items["Molotov"], resalePrice: 3, quantity: 1 },
            ],
            Rare: [
                { item: items["SMGMkII"], resalePrice: 60, quantity: 1 },
                { item: items["Ak47"], resalePrice: 60, quantity: 1 },
            ],
        },
    },

    rustyCase: {
        name: "Rusty Case",
        price: "200",
        categoryId: "trendingCases",

        images: [
            {
                src: "./img/box/case/rusty_case.png",
                class: "test",
            },
            {
                src: "./img/box/items/rusty_knife.png",
                class: "position-absolute item-in-case",
            },
        ],

        items: {
            Common: [
                { item: items["Knife"], resalePrice: 10, quantity: 1 }
            ],
        
            Mythical: [
                { item: items["Ak47"], resalePrice: 250, quantity: 1 }
            ],
        },
    },

    carBox: {
        name: "Car Box",
        price: "200",
        categoryId: "trendingCases",

        images: [
            {
                src: "./img/garage/contour/default_contour.png",
                class: "position-absolute garage_contour",
            },
            {
                src: "./img/garage/door/defaut_door.png",
                class: "position-absolute garage_door",
            },
            {
                src: "./img/garage/car/red_car.png",
                class: "position-absolute garage_car",
            },
            {
                src: "./img/garage/interior/default_interior.png",
                class: "garage_interieur",
            },
        ],

        items: {
            Common: [
                {item: items["RustyCar"], resalePrice: 60, quantity: 1},
                {item: items["RedCar"], resalePrice: 60, quantity: 1},
            ],
    
            Epic: [
                {item: items["GraffityCar"], resalePrice: 100, quantity: 1}
            ],

            Legendary: [
                {item: items["NTRPCar"], resalePrice: 250, quantity: 1}
            ],
        },
    },

    graffityCarCase: {
        name: "Graffity Car Box",
        price: "200",
        categoryId: "carCases",

        images: [
            {
                src: "./img/garage/contour/graffity_contour.png",
                class: "position-absolute garage_contour",
            },
            {
                src: "./img/garage/door/graffity_door.png",
                class: "position-absolute garage_door",
            },
            {
                src: "./img/garage/car/graffity_car.png",
                class: "position-absolute garage_car",
            },
            {
                src: "./img/garage/interior/default_interior.png",
                class: "garage_interieur",
            },
        ],

        items: {
            Common: [
                { item: items["RustyCar"], resalePrice: 60, quantity: 1 }
            ],
        
            Epic: [
                { item: items["GraffityCar"], resalePrice: 60, quantity: 1 }
            ],
        },
    },

    rustyCarCase: {
        name: "Rusty Car Box",
        price: "200",
        categoryId: "carCases",

        images: [
            {
                src: "./img/garage/contour/rusty_contour.png",
                class: "position-absolute garage_contour",
            },
            {
                src: "./img/garage/door/rusty_door.png",
                class: "position-absolute garage_door",
            },
            {
                src: "./img/garage/car/rusty_car.png",
                class: "position-absolute garage_car",
            },
            {
                src: "./img/garage/interior/default_interior.png",
                class: "garage_interieur",
            },
        ],

        items: {
            Common: [
                {item: items["RustyCar"], resalePrice: 30, quantity: 1}
            ],
        
            Legendary: [
                {item: items["NTRPCar"], resalePrice: 300, quantity: 1}
            ],
        },
    },

    newtownCarCase: {
        name: "Newtown Car Box",
        price: "200",
        categoryId: "trendingCases",

        images: [
            {
                src: "./img/garage/contour/newtown_contour.png",
                class: "position-absolute garage_contour",
            },
            {
                src: "./img/garage/door/newtown_door.png",
                class: "position-absolute garage_door",
            },
            {
                src: "./img/garage/car/newtown_car.png",
                class: "position-absolute garage_car",
            },
            {
                src: "./img/garage/interior/newtown_interior.png",
                class: "garage_interieur",
            },
        ],

        items: {
            Rare: [
                {item: items["Molotov"], resalePrice: 60, quantity: 1}
            ],
            Legendary: [
                {item: items["NTRPCar"], resalePrice: 250, quantity: 1}
            ],
        },
    },
};

:eyes: Showcase :eyes:

:globe_with_meridians: Links :globe_with_meridians:

:battery: Performance Idle :battery:

0.00 ms

:books: Other Resources :books:

Code is accessible No (Only config and editable folder)
Subscription-based No
Lines (approximately) 911 (LUA) / 253 (HTML) / 630 (JS) / 205 (Custom CSS)
Requirements ox_lib
Support Yes

can i use items to open this boxes instead of coins?

Currently, no.

However, it’s a good idea that escaped me, so by tonight the script will have this option !

Lootboxes rule violation