CASE

FiveM Case Configuration Guide

Configuration

The configuration file allows you to set up various aspects of the system, such as the database, framework, and integration with Tebex and Discord.

Config File

Config = {}

Config.Tebex = false
Config.Log = "webhook add"
Config.MySQL = "mysql-async" -- mysql-async, oxmysql, or ghmattimysql
Config.Framework = "QBCore" -- QBCore, ESX, OLDQBCore, or NewESX

Config.FormattedToken = "discord-api" -- Add your Discord bot token from https://discord.com/developers/applications

Config.Garage = "qb-garages" -- For qb-garages select 'individual', for other garages select 'all'

Framework Setup

This function determines which framework you are using (QBCore, ESX, OLDQBCore, or NewESX) and fetches the shared object for that framework.

function GetFramework()
    local Get = nil
    if Config.Framework == "ESX" then
        while Get == nil do
            TriggerEvent('esx:getSharedObject', function(Set) Get = Set end)
            Citizen.Wait(0)
        end
    end
    if Config.Framework == "NewESX" then
        Get = exports['es_extended']:getSharedObject()
    end
    if Config.Framework == "QBCore" then
        Get = exports["qb-core"]:GetCoreObject()
    end
    if Config.Framework == "OldQBCore" then
        while Get == nil do
            TriggerEvent('QBCore:GetObject', function(Set) Get = Set end)
            Citizen.Wait(200)
        end
    end
    return Get
end

Discord Integration

These functions allow you to send requests to the Discord API and get user avatars.

function DiscordRequest(method, endpoint, jsondata)
    local data = nil
    PerformHttpRequest("https://discord.com/api/"..endpoint, function(errorCode, resultData, resultHeaders)
        data = {data=resultData, code=errorCode, headers=resultHeaders}
    end, method, #jsondata > 0 and json.encode(jsondata) or "", {["Content-Type"] = "application/json", ["Authorization"] = "Bot " .. Config.FormattedToken})
      
    while data == nil do
        Citizen.Wait(0)
    end
    return data
end

function GetDiscordAvatar(userID)
    local response = DiscordRequest("GET", "users/"..userID, {})
    if response.code == 200 then
        local userData = json.decode(response.data)
        local avatarID = userData.avatar
        local avatarURL = string.format("https://cdn.discordapp.com/avatars/%s/%s.png", userID, avatarID)
        return avatarURL
    else
        return nil
    end
end

HTTP GET Request

This function allows you to make HTTP GET requests.

function HttpGet(url)
    local data = nil
    local error = nil

    PerformHttpRequest(url, function(err, result, headers)
        if err == 200 then
            data = json.decode(result)
        else
            error = err
        end
    end, 'GET')

    while data == nil and error == nil do
        Citizen.Wait(0)
    end

    return data, error
end

Case System Configuration

Define the system configurations for case categories, store gold section, and items that can be found in the case.

Config.System = {
    ["Case Categories"] = {
        {border = "premium", label = "Premium Case", category = "premium"},
        {border = "standard", label = "Basic Case", category = "standard"}
    },
    ["Store Gold Section"] = {
        {price = 175},
        {price = 150},
        {price = 150},
        -- Add more entries as needed
    },
    ["Items that can be found in the safe"] = {
        {id = "bag", border = "aqua"},
        {id = "hoodie", border = "green"},
        {id = "cash", border = "orange"},
        -- Add more items as needed
    }
}

Live Cases

Define the items and categories for live cases.

Config.Live = {
    {
        items = {
            {label = "Zentorno", item = "zentorno", size = 95, sell = 50, type = "car"},
            {label = "Apocalypse - 380", item = "zr380", size = 105, sell = 50, type = "car"},
            -- Add more items as needed
        },
        category = "premium",
        price = 150,
        label = "Deluxe Cars",
        size = "105",
        icon = "car"
    },
    {
        items = {
            {label = "Ammo Pistol", item = "AMMO_PISTOL", size = 80, sell = 50, type = "item"},
            {label = "Ammo MG", item = "AMMO_MG", size = 80, sell = 50, type = "item"},
            -- Add more items as needed
        },
        category = "premium",
        price = 150,
        label = "Ammo Case",
        size = "85",
        icon = "blue"
    },
    {
        items = {
            {label = "Money", item = "money", size = 65, sell = 50, type = "item"},
            {label = "Weed", item = "weed20g", size = 65, sell = 50, type = "item"},
            -- Add more items as needed
        },
        category = "premium",
        price = 150,
        label = "Green Case",
        size = "83",
        icon = "green"
    },
    -- Add more case definitions as needed
}

Standard Cases

Define the items and categories for standard cases.

Config.Standart = {
    {
        items = {
            {label = "Zentorno", item = "zentorno", size = 95, sell = 50, type = "car"},
            {label = "Apocalypse - 380", item = "zr380", size = 105, sell = 50, type = "car"},
            -- Add more items as needed
        },
        price = 150,
        label = "Car Case",
        size = 100,
        icon = "car"
    },
    {
        items = {
            {label = "Auto Shotgun", item = "WEAPON_AUTOSHOTGUN", size = 55, sell = 50, type = "item"},
            {label = "APP Pistol", item = "WEAPON_APPISTOL", size = 50, sell = 50, type = "item"},
            -- Add more items as needed
        },
        price = 150,
        label = "Gun Case",
        size = 100,
        icon = "gun"
    },
    -- Add more case definitions as needed
}

Summary

This guide provides the essential configurations and functions needed to set up your FiveM case system. Customize each section to fit your server's requirements and integrate these configurations into your documentation for clear and comprehensive instructions for your users.

Last updated