Page cover image

Accessible files

Here you can find all the files which can be edite to make the asset compatible with your server.

config.lua
Config = {
    Core = 'ESX',  -- ESX / QBCORE | Other core setting on the 'core' folder and the client and server utils.lua
    BrutalNotify = true, -- Buy here: (4€+VAT) https://store.brutalscripts.com | Or set up your own notify >> cl_utils.lua
    TextUI = 'ox_lib', -- 'ox_lib' / 'okokTextUI' / 'ESXTextUI' / 'QBDrawText' // Custom can be add in the cl_utils.lua!!!
    HideMinimap = true, -- Hide the minimap during the crafting menu is open
    LocallyInvisible = true, -- true or false | If your ANTICHEAT ban the player with 'Invisible' reason, set to false! | If it is false the character will walk out of the camera
    UseLevelSystem = true, -- If you want level system or not
    GiveXpIfFails = false, -- Give xp to the player if they fail the crafting
    LevelSystem = {
        [1] = {
            LevelUP = 30,
            CraftingTimeMultiplier = 1.0, 
            CraftingChanceMultiplier = 1.0, 
        },
        [2] = {
            LevelUP = 50,
            CraftingTimeMultiplier = 0.9, 
            CraftingChanceMultiplier = 1.14, 
        },
        -- You can add more levels with specific configuration
    },
    
    CraftingTables = {
        
        -- HOW TO CREATE A NEW CRAFTING TABLE? CHECK IT OUT! --> https://docs.brutalscripts.com/site/scripts/crafting/creating-a-new-crafting-table

        {
            Label = "WEAPON CRAFTING",
            Model = 'gr_prop_gr_bench_01b',
            Coords = vector3(-625.908, -1628.418, 32.0100),
            Heading = 85.5842,
            CameraSettings = {xOffset = 0.9, yOffset = -1.6, zOffset = 1.4, xRotate = 0.0, yRotate = 0.0, zRotate = 0.0}, -- The Camera's position and rotation relative to the table
            LightSettings = {xOffset = 4.0, yOffset = -4.0, zOffset = 3.0, intensity = 0.045}, -- Where should the light come to the table, also relative to the table
            Spawn = true, -- Wether the script should spawn the given prop for the crafting bench, or not spawn, instead use the existing prop which is at the coords.
            StopCraftingRadius = 5.0, -- After this distance the crafts will be stopped
            ShowBlipradius = 30.0, -- Show the blip on the map after this distance
            ShowMarkerRadius = 10.0, -- Show the marker after this distance
            Color = '#836FFF', -- The main color of the menu | Give the value in hex | https://www.google.com/search?q=color+picker&sca_esv=0573b43c5c641ce9&sxsrf=ACQVn0_-hMLWl_zzSwut9j_3K-mWUc4NRQ%3A1707927207554&ei=p-bMZfmqIcOO9u8P3IOsqAQ&udm=&ved=0ahUKEwi5mojUnKuEAxVDh_0HHdwBC0UQ4dUDCBA&uact=5&oq=color+picker&gs_lp=Egxnd3Mtd2l6LXNlcnAiDGNvbG9yIHBpY2tlcjIKEAAYRxjWBBiwAzIKEAAYRxjWBBiwAzIKEAAYRxjWBBiwAzIKEAAYRxjWBBiwAzIKEAAYRxjWBBiwAzIKEAAYRxjWBBiwAzIKEAAYRxjWBBiwAzIKEAAYRxjWBBiwA0jMGlD9A1j2FXABeAGQAQCYAYoBoAGfCaoBAzEuObgBA8gBAPgBAcICBxAjGLACGCfCAgcQABiABBgNwgIHECMYsQIYJ8ICBxAAGIAEGArCAgoQIxiABBiKBRgnwgIFEAAYgATCAggQABiABBjLAeIDBBgAIEGIBgGQBgg&sclient=gws-wiz-serp
            Blip = {use = true, size = 0.9, sprite = 150, color = 1},
            Marker = {use = true, marker = 20, rgb = {233, 88, 69}, bobUpAndDown = false, rotate = false, position = {xOffset = 0.9, yOffset = -0.6, zOffset = 0.6}},
            Crafts = {
                {
                    Item = 'weapon_assaultshotgun',
                    Label = 'SHOTGUN',
                    Object = 'w_sg_assaultshotgun', -- Use this if you don't find the right objects for the craft: prop_cs_cardbox_01 
                    ObjectSettings = {xOffset = 0.95, yOffset = -0.7, zOffset = 1.25, xRotate = 0.0, yRotate = 0.0, zRotate = 0.0}, -- The Object's position and rotation relative to the table
                    MoveToMouse = true, -- The object is moving as you move your mouse
                    CreatedAmount = 1,
                    XpGive = 2, -- How many xp should one crafting give 
                    SuccessChance = 70, -- In percentages
                    CraftingTime = 10, -- The time to craft the item in seconds
                    Level = 1, -- The level which is needed to use this craft
                    Jobs = {''},
                    Requirements = {
                        {'water', 'Water', 1, false}, -- Item/amount/if the item should be removed when crafting
                    },
                },
                {
                    Item = 'weapon_pumpshotgun',
                    Label = 'PUMP SHOTGUN',
                    Object = 'w_sg_pumpshotgun', -- Use this if you don't find the right objects for the craft: prop_cs_cardbox_01 
                    ObjectSettings = {xOffset = 0.95, yOffset = -0.7, zOffset = 1.3, xRotate = 0.0, yRotate = 0.0, zRotate = 0.0}, -- The Object's position and rotation relative to the table
                    MoveToMouse = true, -- The object is moving as you move your mouse
                    CreatedAmount = 1,
                    XpGive = 2, -- How many xp should one crafting give 
                    SuccessChance = 60, -- In percentages
                    CraftingTime = 10, -- The time to craft the item in seconds
                    Level = 1, -- The level which is needed to use this craft
                    Jobs = {''},
                    Requirements = {
                        {'water', 'Water', 1, false}, -- Item/amount/if the item should be removed when crafting
                    },
                },
                {
                    Item = 'weapon_stungun',
                    Label = 'STUNGUN',
                    Object = 'w_pi_stungun', -- Use this if you don't find the right objects for the craft: prop_cs_cardbox_01 
                    ObjectSettings = {xOffset = 0.95, yOffset = -0.9, zOffset = 1.3, xRotate = 0.0, yRotate = 0.0, zRotate = 0.0}, -- The Object's position and rotation relative to the table
                    MoveToMouse = true, -- The object is moving as you move your mouse
                    CreatedAmount = 1,
                    XpGive = 2, -- How many xp should one crafting give 
                    SuccessChance = 60, -- In percentages
                    CraftingTime = 10, -- The time to craft the item in seconds
                    Level = 1, -- The level which is needed to use this craft
                    Jobs = {''},
                    Requirements = {
                        {'water', 'Water', 1, false}, -- Item/amount/if the item should be removed when crafting
                    },
                },
                {
                    Item = 'ammo-9',
                    Label = 'AMMO 9mm',
                    Object = 'prop_box_ammo07b', -- Use this if you don't find the right objects for the craft: prop_cs_cardbox_01 
                    ObjectSettings = {xOffset = 0.95, yOffset = -0.8, zOffset = 1.3, xRotate = 20.0, yRotate = 0.0, zRotate = 0.0}, -- The Object's position and rotation relative to the table
                    MoveToMouse = true, -- The object is moving as you move your mouse
                    CreatedAmount = 10,
                    XpGive = 2, -- How many xp should one crafting give 
                    SuccessChance = 60, -- In percentages
                    CraftingTime = 10, -- The time to craft the item in seconds
                    Level = 1, -- The level which is needed to use this craft
                    Jobs = {''},
                    Requirements = {
                        {'water', 'Water', 1, false}, -- Item/amount/if the item should be removed when crafting
                    },
                },
            },

        },

        {
            Label = "DRUG CRAFTING",
            Model = 'prop_tool_bench02_ld',
            Coords = vector3(244.732, 3111.310, 41.491),
            Heading = 94.5842,
            CameraSettings = {xOffset = 0.9, yOffset = 0.0, zOffset = 1.4, xRotate = 0.0, yRotate = 0.0, zRotate = 90.0}, -- The Camera's position and rotation relative to the table  
            LightSettings = {xOffset = 4.0, yOffset = 0.0, zOffset = 3.0, intensity = 0.025}, -- Where should the light come to the table, also relative to the table
            Spawn = true, -- Wether the script should spawn the given prop for the crafting bench, or not spawn, instead use the existing prop which is at the coords.
            StopCraftingRadius = 5.0, -- After this distance the crafts will be stopped
            ShowBlipradius = 30.0, -- Show the blip on the map after this distance
            ShowMarkerRadius = 10.0, -- Show the marker after this distance
            Color = '#789461', -- The main color of the menu | Give the value in hex | https://www.google.com/search?q=color+picker&sca_esv=0573b43c5c641ce9&sxsrf=ACQVn0_-hMLWl_zzSwut9j_3K-mWUc4NRQ%3A1707927207554&ei=p-bMZfmqIcOO9u8P3IOsqAQ&udm=&ved=0ahUKEwi5mojUnKuEAxVDh_0HHdwBC0UQ4dUDCBA&uact=5&oq=color+picker&gs_lp=Egxnd3Mtd2l6LXNlcnAiDGNvbG9yIHBpY2tlcjIKEAAYRxjWBBiwAzIKEAAYRxjWBBiwAzIKEAAYRxjWBBiwAzIKEAAYRxjWBBiwAzIKEAAYRxjWBBiwAzIKEAAYRxjWBBiwAzIKEAAYRxjWBBiwAzIKEAAYRxjWBBiwA0jMGlD9A1j2FXABeAGQAQCYAYoBoAGfCaoBAzEuObgBA8gBAPgBAcICBxAjGLACGCfCAgcQABiABBgNwgIHECMYsQIYJ8ICBxAAGIAEGArCAgoQIxiABBiKBRgnwgIFEAAYgATCAggQABiABBjLAeIDBBgAIEGIBgGQBgg&sclient=gws-wiz-serp
            Blip = {use = true, size = 0.9, sprite = 51, color = 4},
            Marker = {use = true, marker = 20, rgb = {233, 88, 69}, bobUpAndDown = false, rotate = false, position = {xOffset = 0.7, yOffset = -0.0, zOffset = 0.6}},
            Crafts = {
                {
                    Item = 'cocain',
                    Label = 'COCAIN',
                    Object = 'ex_office_swag_drugbags', -- Use this if you don't find the right objects for the craft: prop_cs_cardbox_01 
                    ObjectSettings = {xOffset = 0.2, yOffset = -0.0, zOffset = 1.2, xRotate = 0.0, yRotate = 0.0, zRotate = 90.0}, -- The Object's position and rotation relative to the table
                    MoveToMouse = true, -- The object is moving as you move your mouse
                    CreatedAmount = 1,
                    XpGive = 2, -- How many xp should one crafting give 
                    SuccessChance = 70, -- In percentages
                    CraftingTime = 10, -- The time to craft the item in seconds
                    Level = 1, -- The level which is needed to use this craft
                    Jobs = {''},
                    Requirements = {
                        {'water', 'Water', 1, false}, -- Item/amount/if the item should be removed when crafting
                    },
                },
                {
                    Item = 'canabis',
                    Label = 'CANABIS',
                    Object = 'hei_prop_pill_bag_01', -- Use this if you don't find the right objects for the craft: prop_cs_cardbox_01 
                    ObjectSettings = {xOffset = 0.2, yOffset = -0.0, zOffset = 1.2, xRotate = 0.0, yRotate = 0.0, zRotate = 90.0}, -- The Object's position and rotation relative to the table
                    MoveToMouse = true, -- The object is moving as you move your mouse
                    CreatedAmount = 1,
                    XpGive = 2, -- How many xp should one crafting give 
                    SuccessChance = 70, -- In percentages
                    CraftingTime = 10, -- The time to craft the item in seconds
                    Level = 1, -- The level which is needed to use this craft
                    Jobs = {''},
                    Requirements = {
                        {'water', 'Water', 1, false}, -- Item/amount/if the item should be removed when crafting
                    },
                },
                {
                    Item = 'heroin',
                    Label = 'HEROIN',
                    Object = 'prop_drug_bottle', -- Use this if you don't find the right objects for the craft: prop_cs_cardbox_01 
                    ObjectSettings = {xOffset = 0.2, yOffset = 0.0, zOffset = 1.2, xRotate = 0.0, yRotate = 0.0, zRotate = 90.0}, -- The Object's position and rotation relative to the table
                    MoveToMouse = true, -- The object is moving as you move your mouse
                    CreatedAmount = 1,
                    XpGive = 2, -- How many xp should one crafting give 
                    SuccessChance = 70, -- In percentages
                    CraftingTime = 10, -- The time to craft the item in seconds
                    Level = 1, -- The level which is needed to use this craft
                    Jobs = {''},
                    Requirements = {
                        {'water', 'Water', 1, false}, -- Item/amount/if the item should be removed when crafting
                    },
                },
            },

        },

        /*{
            Label = "MECHANIC CRAFTING",
            Model = 'imp_prop_impexp_mechbench',
            Coords = vector3(-241.8248, -1338.1680, 29.9028),
            Heading = 200.5842,
            CameraSettings = {xOffset = 0.9, yOffset = -1.6, zOffset = 1.4, xRotate = 0.0, yRotate = 0.0, zRotate = 0.0}, -- The Camera's position and rotation relative to the table
            LightSettings = {xOffset = 0.0, yOffset = -4.0, zOffset = 3.0, intensity = 0.025}, -- Where should the light come to the table, also relative to the table
            Spawn = false, -- Wether the script should spawn the given prop for the crafting bench, or not spawn, instead use the existing prop which is at the coords.
            StopCraftingRadius = 5.0, -- After this distance the crafts will be stopped
            ShowBlipradius = 30.0, -- Show the blip on the map after this distance
            ShowMarkerRadius = 10.0, -- Show the marker after this distance
            Color = '#395086', -- The main color of the menu | Give the value in hex | https://www.google.com/search?q=color+picker&sca_esv=0573b43c5c641ce9&sxsrf=ACQVn0_-hMLWl_zzSwut9j_3K-mWUc4NRQ%3A1707927207554&ei=p-bMZfmqIcOO9u8P3IOsqAQ&udm=&ved=0ahUKEwi5mojUnKuEAxVDh_0HHdwBC0UQ4dUDCBA&uact=5&oq=color+picker&gs_lp=Egxnd3Mtd2l6LXNlcnAiDGNvbG9yIHBpY2tlcjIKEAAYRxjWBBiwAzIKEAAYRxjWBBiwAzIKEAAYRxjWBBiwAzIKEAAYRxjWBBiwAzIKEAAYRxjWBBiwAzIKEAAYRxjWBBiwAzIKEAAYRxjWBBiwAzIKEAAYRxjWBBiwA0jMGlD9A1j2FXABeAGQAQCYAYoBoAGfCaoBAzEuObgBA8gBAPgBAcICBxAjGLACGCfCAgcQABiABBgNwgIHECMYsQIYJ8ICBxAAGIAEGArCAgoQIxiABBiKBRgnwgIFEAAYgATCAggQABiABBjLAeIDBBgAIEGIBgGQBgg&sclient=gws-wiz-serp
            Blip = {use = true, size = 0.9, sprite = 402, color = 0},
            Marker = {use = true, marker = 20, rgb = {233, 88, 69}, bobUpAndDown = false, rotate = false, position = {xOffset = 0.0, yOffset = -0.6, zOffset = 0.6}},
            Crafts = {
                {
                    Item = 'vehicle_tyre',
                    Label = 'VEHICLE TYRE',
                    Object = 'prop_wheel_tyre', -- Use this if you don't find the right objects for the craft: prop_cs_cardbox_01 
                    ObjectSettings = {xOffset = 0.95, yOffset = -0.4, zOffset = 1.0, xRotate = 0.0, yRotate = 0.0, zRotate = 0.0}, -- The Object's position and rotation relative to the table
                    MoveToMouse = true, -- The object is moving as you move your mouse
                    CreatedAmount = 1,
                    XpGive = 2, -- How many xp should one crafting give 
                    SuccessChance = 63, -- In percentages
                    CraftingTime = 10, -- The time to craft the item in seconds
                    Level = 1, -- The level which is needed to use this craft
                    Jobs = {'mechanic'},
                    Requirements = {
                        {'bolt', 'BOLT', 6, false}, -- Item/Label/Amount/if the item should be removed when crafting
                        {'rubber', 'RUBBER', 1, false},
                    },
                },
                {
                    Item = 'vehicle_door',
                    Label = 'VEHICLE DOOR',
                    Object = 'imp_prop_impexp_car_door_01a', -- Use this if you don't find the right objects for the craft: prop_cs_cardbox_01 
                    ObjectSettings = {xOffset = 0.4, yOffset = -0.2, zOffset = 0.8, xRotate = 2.0, yRotate = -2.0, zRotate = 90.0}, -- The Object's position and rotation relative to the table
                    MoveToMouse = false, -- The object is moving as you move your mouse
                    CreatedAmount = 1,
                    XpGive = 2, -- How many xp should one crafting give 
                    SuccessChance = 78, -- In percentages
                    CraftingTime = 10, -- The time to craft the item in seconds
                    Level = 1, -- The level which is needed to use this craft
                    Jobs = {'mechanic'},
                    Requirements = {
                        {'bolt', 'BOLT', 3, false}, -- Item/Label/Amount/if the item should be removed when crafting
                        {'scrap_metal', 'SCRAP METAL', 3, false},
                        {'steel', 'STEEL', 1, false},
                    },
                },
                {
                    Item = 'tool_box',
                    Label = 'TOOL BOX',
                    Object = 'prop_tool_box_04', -- Use this if you don't find the right objects for the craft: prop_cs_cardbox_01 
                    ObjectSettings = {xOffset = 1.0, yOffset = -0.5, zOffset = 1.15, xRotate = 0.0, yRotate = 0.0, zRotate = 0.0}, -- The Object's position and rotation relative to the table
                    MoveToMouse = true, -- The object is moving as you move your mouse
                    CreatedAmount = 1,
                    XpGive = 2, -- How many xp should one crafting give 
                    SuccessChance = 82, -- In percentages
                    CraftingTime = 10, -- The time to craft the item in seconds
                    Level = 1, -- The level which is needed to use this craft
                    Jobs = {'mechanic'},
                    Requirements = {
                        {'scrap_metal', 'SCRAP METAL', 2, false}, -- Item/Label/Amount/if the item should be removed when crafting
                        {'bolt', 'BOLT', 5, false},
                    },
                },
                {
                    Item = 'vehicle_window',
                    Label = 'WINDOW',
                    Object = 'apa_prop_yacht_glass_04', -- Use this if you don't find the right objects for the craft: prop_cs_cardbox_01 
                    ObjectSettings = {xOffset = 1.0, yOffset = -0.2, zOffset = 1.0, xRotate = 0.0, yRotate = 0.0, zRotate = 0.0}, -- The Object's position and rotation relative to the table
                    MoveToMouse = true, -- The object is moving as you move your mouse
                    CreatedAmount = 1,
                    XpGive = 2, -- How many xp should one crafting give 
                    SuccessChance = 65, -- In percentages
                    CraftingTime = 10, -- The time to craft the item in seconds
                    Level = 1, -- The level which is needed to use this craft
                    Jobs = {'mechanic'},
                    Requirements = {
                        {'glass', 'GLASS', 3, true}, -- Item/Label/Amount/if the item should be removed when crafting
                    },
                },
                {
                    Item = 'suspension',
                    Label = 'SUSPENSION',
                    Object = 'v_ind_cs_blowtorch', -- Use this if you don't find the right objects for the craft: prop_cs_cardbox_01 
                    ObjectSettings = {xOffset = 1.0, yOffset = -0.8, zOffset = 1.15, xRotate = 0.0, yRotate = 0.0, zRotate = 90.0}, -- The Object's position and rotation relative to the table
                    MoveToMouse = true, -- The object is moving as you move your mouse
                    CreatedAmount = 1,
                    XpGive = 2, -- How many xp should one crafting give 
                    SuccessChance = 71, -- In percentages
                    CraftingTime = 10, -- The time to craft the item in seconds
                    Level = 1, -- The level which is needed to use this craft
                    Jobs = {'mechanic'},
                    Requirements = {
                        {'bolt', 'BOLT', 1, false}, -- Item/Label/Amount/if the item should be removed when crafting
                        {'steel', 'STEEL', 3, false},
                    },
                },
            },

        },*/
    },
-----------------------------------------------------------
-----------------------| TRANSLATE |-----------------------
-----------------------------------------------------------

    MoneyForm = '$',

    Texts = {
        [1] = {'[E] - To open the crafting table', 38},
    },

    Notify = {
        [1] =  {'Notification', "You are using another crafting table!", 5000, 'error'},
        [2] =  {'Notification', "You don't have enough items for the craft!", 5000, 'error'},
        [3] =  {'Notification', "You can't craft inside of a vehicle!", 5000, 'error'},
        [4] =  {'Notification', "Finished crafting. Claim in the menu!", 5000, 'success'},
        [5] =  {'Notification', "You went too far away to craft!", 5000, 'error'},
    },

    Webhooks = {
        Locale = {
            ['Crafted'] = '🛠️ Successful Crafting', -- Title
            ['FailedtoCraft'] = '❌ Failed Crafting', -- Title
            ['Hacker'] = '❌ Probably Hacking', -- Title

            ['HasCarfted'] = 'Crafted', -- Description
            ['HasFailedtoCraft'] = 'Failed to craft', -- Description
            ['HackerDescription'] = 'Tried to add item(s)', -- Description

            ['Identifier'] = 'Identifier',

            ['Time'] = 'Time ⏲️'
        },

        -- To change a webhook color you need to set the decimal value of a color, you can use this website to do that - https://www.mathsisfun.com/hexadecimal-decimal-colors.html
        Colors = {
            ['Crafted'] = 3145631, 
            ['FailedtoCraft'] = 16711680,
            ['Hacker'] = 16711680,
        }
    },
}
client-utils.lua
ESX = Core
QBCore = Core

-- Buy here: (4€+VAT) https://store.brutalscripts.com
function notification(title, text, time, type)
    if Config.BrutalNotify then
        exports['brutal_notify']:SendAlert(title, text, time, type)
    else
        -- Put here your own notify and set the Config.BrutalNotify to false
        SetNotificationTextEntry("STRING")
        AddTextComponentString(text)
        DrawNotification(0,1)

        -- Default ESX Notify:
        --TriggerEvent('esx:showNotification', text)

        -- Default QB Notify:
        --TriggerEvent('QBCore:Notify', text, 'info', 5000)

        -- OKOK Notify:
        -- exports['okokNotify']:Alert(title, text, time, type, false)
    end
end

function TextUIFunction(type, text)
    if type == 'open' then
        if Config.TextUI:lower() == 'ox_lib' then
            lib.showTextUI(text)
        elseif Config.TextUI:lower() == 'okoktextui' then
            exports['okokTextUI']:Open(text, 'darkblue', 'right')
        elseif Config.TextUI:lower() == 'esxtextui' then
            ESX.TextUI(text)
        elseif Config.TextUI:lower() == 'qbdrawtext' then
            exports['qb-core']:DrawText(text,'left')
        end
    elseif type == 'hide' then
        if Config.TextUI:lower() == 'ox_lib' then
            lib.hideTextUI()
        elseif Config.TextUI:lower() == 'okoktextui' then
            exports['okokTextUI']:Close()
        elseif Config.TextUI:lower() == 'esxtextui' then
            ESX.HideUI()
        elseif Config.TextUI:lower() == 'qbdrawtext' then
            exports['qb-core']:HideText()
        end
    end
end

function OpenMenuUtil()
    SetNuiFocus(true, true)
    if Config.HideMinimap then
        DisplayRadar(false)
    end
    Citizen.CreateThread(function()
        while InMenu do
            N_0xf4f2c0d4ee209e20() -- it's disable the AFK camera zoom
            Citizen.Wait(15000)
        end 
    end)
end

function CloseMenuUtil()
    SetNuiFocus(false, false)
    if Config.HideMinimap then
        DisplayRadar(true)
    end
end

function SetPlayerInvisible()
    Citizen.CreateThread(function()
        local entity = PlayerPedId()
        while InMenu and Config.LocallyInvisible do
            Wait(0)
            SetEntityLocallyInvisible(entity)
        end
    end)
end
server-utils.lua
local YourWebhook = 'Your-Webhook'  -- help: https://docs.brutalscripts.com/site/others/discord-webhook

function GetWebhook()
    return YourWebhook
end

function PlayerNameFunction(source)
    return GetPlayerName(source)
end
client-core.lua
Core = nil

if Config['Core']:upper() == 'ESX' then
    
    local _esx_ = 'new' -- 'new' / 'old'

    if _esx_ then
        Core = exports['es_extended']:getSharedObject()
    else
        while Core == nil do
            TriggerEvent('esx:getSharedObject', function(obj) Core = obj end)
            Citizen.Wait(0)
        end
    end
    
    LoadedEvent = 'esx:playerLoaded'
    TSCB = Core.TriggerServerCallback

    function GetPlayerJobDatas()
        return Core.GetPlayerData().job
    end

elseif Config['Core']:upper() == 'QBCORE' then

    Core = exports['qb-core']:GetCoreObject()
    TSCB = Core.Functions.TriggerCallback
    LoadedEvent = 'QBCore:Client:OnPlayerLoaded'
    
    function GetPlayerJobDatas()
        return Core.Functions.GetPlayerData().job
    end

end
server-core.lua
Core = nil

if Config['Core']:upper() == 'ESX' then
--------------------------------------------------------------------------
---------------------------------| ESX |----------------------------------
--------------------------------------------------------------------------

    local _esx_ = 'new' -- 'new' / 'old'
        
    if _esx_ == 'new' then
        Core = exports['es_extended']:getSharedObject()
    else
        Core = nil
        TriggerEvent('esx:getSharedObject', function(obj) Core = obj end)
        while Core == nil do
            Citizen.Wait(0)
        end
    end

    RESCB = Core.RegisterServerCallback
    GETPFI = Core.GetPlayerFromId
    RUI = Core.RegisterUsableItem

    function GetPlayerJobFunction(source)
        local xPlayer = GETPFI(source)
        if xPlayer ~= nil then
            PlayerJob = xPlayer.job.name
        else
            PlayerJob = ''
        end
        return PlayerJob
    end

    function GetItemCount(source, item)
        local xPlayer = GETPFI(source)

        if _esx_ == 'new' then
            return xPlayer.getInventoryItem(item).count
        else
            if string.sub(item, 0, 6):lower() == 'weapon' then
                local loadoutNum, weapon = xPlayer.getWeapon(item:upper())

                if weapon then
                    return true
                else
                    return false
                end
            else
                return xPlayer.getInventoryItem(item).count
            end
        end
    end

    function AddItem(source, item, count)
        local xPlayer = GETPFI(source)
        if _esx_ == 'new' then
            xPlayer.addInventoryItem(item, count)
        else
            if string.sub(item, 0, 6):lower() == 'weapon' then
                xPlayer.addWeapon(item, 90)
            else
                xPlayer.addInventoryItem(item, count)
            end
        end
    end

    function RemoveItem(source, item, amount)
        local xPlayer = GETPFI(source)
        if _esx_ == 'new' then
            xPlayer.removeInventoryItem(item, amount)
        else
            if string.sub(item, 0, 6):lower() == 'weapon' then
                xPlayer.removeWeapon(item)
            else
                xPlayer.removeInventoryItem(item, amount)
            end
        end
    end

    function GetIdentifierFunction(source)
        local xPlayer = GETPFI(source)
        return xPlayer.identifier
    end

elseif Config['Core']:upper() == 'QBCORE' then
--------------------------------------------------------------------------
--------------------------------| QBCORE |--------------------------------
--------------------------------------------------------------------------

    Core = exports['qb-core']:GetCoreObject()
    
    RESCB = Core.Functions.CreateCallback
    GETPFI = Core.Functions.GetPlayer
    RUI = Core.Functions.CreateUseableItem

    function GetPlayerJobFunction(source)
        local xPlayer = GETPFI(source)
        PlayerJob = xPlayer.PlayerData.job.name
        return PlayerJob
    end

    function GetItemCount(source, item)
        local xPlayer = GETPFI(source)

        local items = xPlayer.Functions.GetItemByName(item)
        local item_count = 0
        if items ~= nil then
            item_count = items.amount
        else
            item_count = 0
        end
        return item_count
    end

    function AddItem(source, item, count)
        local xPlayer = GETPFI(source)
        xPlayer.Functions.AddItem(item, count)
    end

    function RemoveItem(source, item, amount)
        local xPlayer = GETPFI(source)
        xPlayer.Functions.RemoveItem(item, amount)
    end

    function GetIdentifierFunction(source)
        local xPlayer = GETPFI(source)
        return xPlayer.PlayerData.citizenid
    end
    
end

Last updated

Was this helpful?