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
}
}
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.