Brutal Scripts
YouTubeDiscordStore
  • 🙉About Us
  • ↗️Translate
  • Informations
    • 🔒Escrow System
    • 🔥Common Problems
  • Scripts
    • 📄Notify
      • Accessible files
      • Installation guide
    • 🔠Text-UI
      • Installation guide
      • Exports & How to use
      • Integrations
    • 🤟Gangs
      • Accessible files
      • Installation guide
      • exports / triggers
      • Create a new gang
    • 🏡Housing
      • Accessible files
      • Installation guide
      • exports / triggers
    • 🔑Keys
      • Accessible files
      • Installation guide
      • exports / triggers
    • 💥Gang Actions
      • Accessible files
      • Installation guide
      • exports / triggers
      • Controlling the menu
    • ⭕Radial
      • Accessible files
      • Installation guide
      • Adding new buttons
    • 🎯Executions
      • Accessible files
      • Installation guide
      • exports / triggers
    • 🐶Pets + K9 V2
      • Accessible files
      • Installation guide
    • 👮Police Job
      • Accessible files
      • Installation guide
      • exports / triggers
    • 🚑Ambulance Job
      • Accessible files
      • Installation guide
      • exports / triggers
    • 🔧Mechanic Job
      • Accessible files
      • Installation guide
      • exports / triggers
    • 💪GYM with Skills V2
      • Accessible files
      • Installation guide
      • exports / triggers
    • 🔫Paintball
      • Accessible files
      • Installation guide
      • exports / triggers
    • 🥊Boxing
      • Accessible files
      • Installation guide
      • exports / triggers
    • 🔨Crafting
      • Accessible files
      • Installation guide
      • Creating a new crafting table
    • 🏦Banking
      • Accessible files
      • Installation guide
      • Paycheck transactions
      • Registering transactions
    • 🎳Bowling
      • Accessible files
      • Installation guide
      • exports / triggers
    • 🦌Hunting
      • Accessible files
      • Installation guide
    • 🏁Racing Script
      • Accessible files
      • Installation guide
    • 🐛Reports
      • Accessible files
      • Installation guide
    • 🛒Shop Robbery
      • Accessible files
      • Installation guide
    • 🛥️Yacht Heist
      • Accessible files
      • Installation guide
    • 🧾Billing
      • Accessible files
      • Installation guide
      • Triggers
    • 💰Truck Robbery
      • Accessible files
      • Installation guide
    • 🏧Atm Robbery
      • Accessible files
      • Installation guide
    • 👶Baby script
      • Installation guide
      • How to add more babys
  • Others
    • Register Key Mapping
    • Drill Minigame
    • Discord Webhook
Powered by GitBook
On this page

Was this helpful?

  1. Scripts
  2. Executions

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.
    Inventory = 'ox_inventory', -- 'ox_inventory' / 'qb_inventory' / 'quasar_inventory' / 'chezza_inventory' / 'codem_inventory' / 'core_inventory' // Custom can be add in the cl_utils.lua!!!
    TextUI = 'brutal_textui', -- false / 'brutal_textui' / 'ox_lib' / 'okokTextUI' / 'ESXTextUI' / 'QBDrawText' // Custom can be add in the cl_utils.lua!!!
    BrutalNotify = true, -- Buy here: (4€+VAT) https://store.brutalscripts.com | Or set up your own notify >> cl_utils.lua
    SteamName = true, -- true = Steam name | false = character name
    DateFormat = '%d/%m/%Y', -- Date format
    ClosestDistanceIssue = false, -- DO NOT EDIT IT.

    BrutalGangs = true, -- Buy here: https://store.brutalscripts.com | Or set up your own notify >> cl_utils.lua

    ColorOf3DUI = "blue", -- "green" / "red" / "blue" / "yellow" / "orange"
    Marker = {use = true, marker = 20, bobUpAndDown = true, rotate = false, size = {0.3, 0.2, 0.2}, rgb = {15, 100, 210}},
    Marker2 = {use = true, marker = 21, bobUpAndDown = true, rotate = false, size = {1.0, 1.0, 0.5}, rgb = {15, 100, 210}},

    TimeForExecution = 30, -- in minutes
    ExecutionRepeatable = 24, -- in hours

    Executions = {
        train = {
            Label = "TRAIN HIT EXECUTION",
            Description = "Tie up the target and place them on the train tracks. Watch as the train takes care of the rest.",
            Price = 300, 

            ReputationAmount = 1000, -- that's how many reputation points the players get for executions

            TrainSpawnTime = {min = 60, max = 180},
            DisableControls = {24,257,25,263,32,34,31,30,45,22,44,37,23,288,289,170,167,73,199,59,71,72,36,47,264,257,140,141,142,143,75},
            Coords = {
                {
                    railway_line = vector3(2672.0593, 3028.9395, 41.4648),
                    train_spawn = vector4(2197.2969, 2621.8513, 51.2507, 295.4281)
                },

                -- you can add more...
            },

            PreparationCoords = {
                vector4(1486.5265, 1131.6558, 114.3366, 358.6116),
                -- you can add more...
            }
        },

        carbomb = {
            Label = "CAR BOMB SETUP",
            Description = "Place the target inside a vehicle, rig it with explosives, and detonate the car remotely.",
            Price = 300, 

            ReputationAmount = 1000, -- that's how many reputation points the players get for executions

            BombTimer = 600, -- in second

            PreparationCoords = {
                {
                    coords = vector3(245.9660, -1967.7738, 21.9617),
                    npcs = {
                        {coords = vector4(245.3465, -1967.0980, 21.9617, 234.9360), model = "g_m_y_ballaorig_01"},
                        {coords = vector4(245.0044, -1968.1914, 21.9617, 287.7616), model = "g_m_y_ballaeast_01"},
                        {coords = vector4(246.2626, -1966.7537, 21.9617, 176.9413), model = "g_m_y_ballasout_01"}
                    }
                },

                -- you can add more...
            }
        },

        boat = {
            Label = "THROWING OVERBOARD",
            Description = "Bind the target with ropes and throw them overboard. Watch as the water ensures they won’t resurface.",
            Price = 300, 

            ReputationAmount = 1000, -- that's how many reputation points the players get for executions

            Boat = "squalo",

            Coords = {
                {
                    boat_request = vector3(712.0440, 4110.3691, 31.2997),
                    boat_spawn = vector4(709.4126, 4108.8662, 29.6299, 177.4471),
                    throwing = vector3(890.5597, 3896.8210, 30.0630),
                },
                -- you can add more...
            },

            PreparationCoords = {
                {
                    coords = vector3(709.8527, 4109.4048, 31.4847),
                    boat_spawn = vector4(709.4126, 4108.8662, 29.6299, 177.4471)
                },
                -- you can add more...
            }
        },
    },

    Commands = {
        ExecutionsMenu = {
            Command = 'executions', 
            Control = '',  -- Controls list:  https://docs.fivem.net/docs/game-references/input-mapper-parameter-ids/keyboard/
            Suggestion = 'To open the executions menu'
        },

        CutRope = {
            Command = 'cutrope', 
            Suggestion = 'To cut the rope',

            KnifeNeeded = true, -- true / false
            AcceptedKnifes = {'WEAPON_KNIFE', 'WEAPON_SWITCHBLADE', 'WEAPON_DAGGER'},
        },

        BombSetup = {
            Command = 'bombsetup', 
            Suggestion = 'To setup the bomb'
        },

        BombDetonator = {
            Command = 'bombdetonator', 
            Suggestion = 'To open the bomb detonator'
        },

        BombDeactivation = {
            Command = 'bombdeactivation', 
            Suggestion = 'To deactivate the bomb',
            
            ItemNeeded = true,
            Item = "pliers"
        },
    },

   
    -----------------------------------------------------------
    -----------------------| TRANSLATE |-----------------------
    -----------------------------------------------------------

    MoneyForm = '$', -- Money form

    Locales = {
        CurrencyForm = "USD",
        ReputationForm = "REP",

        Preparation = "Preparation",
        Execution = "Execution",

        Preparations = {
            train = "Go to the designated place where you have to steal the rope!",
            carbomb = "Go to the designated place where you have to talk to the bomb dealers!",
            boat = "Go to the designated place where you have to break the boat's lock!"
        },

        Executions = {
            train = "Take the player to the designated location and tie them to the tracks!",
            carbomb = "Install the bomb in a car using the /bombsetup command!",
            carbomb2 = "Use the /bombdetonator command to blow up the car!",
            boat = "Throw the player off the boat into the water while their hands are tied!",
        },

        SuccessExecution = "The execution was completed successfully!"
    },

    Texts = {
        [1] = {'[E] - Select Player', 38},
        [2] = {'[E] - Tying to the tracks', 38},
        [3] = {'[E] - Placing a bomb', 38},
        [4] = {'[E] - Retrieve boat', 38},
        [5] = {'[E] - To start the Task', 38},
        [6] = {'[E] - Stopping the boat', 38},
        [7] = {'[E] - Toss player overboard', 38},
    },
    
    -- Notify function EDITABLE >> cl_utils.lua
    Notify = { 
        [1] = {"Executions", "The player has to be free!", 5000, "error"},
        [2] = {"Executions", "You cannot start at the moment!", 5000, "error"},
        [3] = {"Executions", "You don't have enough money!", 5000, "error"},
        [4] = {"Executions", "The player is too far away!", 5000, "error"},
        [5] = {"Executions", "The bomb has been deactivated!", 5000, "info"},
        [6] = {"Executions", "You have successfully deactivated the bomb!", 5000, "success"},
        [7] = {"Executions", "You are under a time limit! You have to wait!", 5000, "error"},
        [8] = {"Executions", "The time is up! (You had 30 minutes!)", 5000, "error"},
        [9] = {"Executions", "You have successfully got the information and the tools you need!", 5000, "success"},
        [10] = {"Executions", "You failed!", 5000, "error"},
        [11] = {"Executions", "Successful theft! Leave the boat!", 5000, "success"},
        [12] = {"Executions", "Place the bomb on the car!", 5000, "info"},
        [13] = {"Executions", "Go to the designated place!", 5000, "info"},
        [14] = {"Executions", "Noone is near you!", 5000, "info"},
        [15] = {"Executions", "You must have a knife in your hand!", 5000, "error"},
        [16] = {"Executions", "There is no vehicle nearby!", 5000, "error"},
        [17] = {"Executions", "You can't be in the car!", 5000, "error"},
        [18] = {"Executions", "No bomb in the car!", 5000, "info"},
        [19] = {"Executions", "You've cut the rope!", 5000, "success"},
        [20] = {"Executions", "You have been successfully saved!", 5000, "success"},
        [21] = {"Executions", "The target cannot be in the vehicle!", 5000, "error"},
        [22] = {"Executions", "You do not have the necessary item! (Pliers)", 5000, "error"},
        [23] = {"Executions", "There is already one in progress!", 5000, "error"},
    },
    
    Webhooks = {
        Locale = {
            ['editGangDatas1'] = "⌛ Gang details updated...",

            ['editGangDatas2'] = "edited the gang's data.",

            ['Identifier'] = "Identifier",
            ['GangName'] = "Gang Name",
            ['GangLabel'] = "Gang Label",
            ['Balance'] = "Balance",
            ['Reputation'] = "Reputation Points",
            ['Status'] = "Status 📈",
            ['Enemy'] = "Enemy 😈",
            ['TargetGang'] = "Target Gang",
            ['Table'] = "Table",
            ['Lost'] = "LOST",
            ['Won'] = "WON",

            ['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 = {
            ['editGangDatas1'] = 3093151, 
        }
    },
}
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('POLICE JOB',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')
        elseif Config.TextUI:lower() == 'brutal_textui' then
            exports['brutal_textui']:Open(text, "blue")
        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()
        elseif Config.TextUI:lower() == 'brutal_textui' then
            exports['brutal_textui']:Close()
        end
    end
end

function isPlayerDead()
    if GetResourceState("brutal_ambulancejob") == "started" then
        return exports.brutal_ambulancejob:IsDead()
    else
        if IsEntityDead(PlayerPedId()) then
            return true
        else
            return false
        end
    end
end

function isEntityClear(targetID)
    local clear = true
    if IsEntityPlayingAnim(GetPlayerPed(GetPlayerFromServerId(targetID)), "nm", "firemans_carry", 3) then
        clear = false
    end

    return clear
end

function OpenMenuUtil()
    InMenu = true
    SetNuiFocus(true, true)

    Citizen.CreateThread(function()
        while InMenu do
            N_0xf4f2c0d4ee209e20() -- it's disable the AFK camera zoom
            Citizen.Wait(15000)
        end 
    end)

    DisplayRadar(false)
end

function DisableMinimap()
    DisplayRadar(false)
    -- Here you can add a trigger to hide your HUD system
end

function EnableMinimap()
    DisplayRadar(true)
    -- Here you can add a trigger to enable your HUD system
end
server-utils.lua
Core = nil

if Config['Core']:upper() == 'ESX' then
    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
    SetJobEvent = 'esx:setJob'
    onPlayerDeath = 'esx:onPlayerDeath'
    UsersDataTable = 'users'
    UserIdentifierValue = 'identifier'

    function GetIdentifier(source)
        local xPlayer = GETPFI(source)
        while xPlayer == nil do
            Citizen.Wait(1000)
            xPlayer = GETPFI(source) 
        end
        return xPlayer.identifier
    end

    function GetPlayerByIdentifier(identifier)
        return Core.GetPlayerFromIdentifier(identifier)
    end

    function GetAccountMoney(source,account)
        local xPlayer = GETPFI(source)
        if account == 'bank' then
            return xPlayer.getAccount(account).money
        elseif account == 'money' then
            return xPlayer.getMoney()
        end
    end

    function AddMoneyFunction(source, account, amount)
        local xPlayer = GETPFI(source)
        if account == 'bank' then
            xPlayer.addAccountMoney('bank', amount)
        elseif account == 'money' then
            xPlayer.addMoney(amount)
        end
    end

    function RemoveAccountMoney(source, account, amount)
        local xPlayer = GETPFI(source)
        if account == 'bank' then
            xPlayer.removeAccountMoney('bank', amount)
        elseif account == 'money' then
            xPlayer.removeMoney(amount)
        end
    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 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 AddItem(source, item, count, info)
        local xPlayer = GETPFI(source)
        if _esx_ == 'new' then
            xPlayer.addInventoryItem(item, count, info)
        else
            if string.sub(item, 0, 6):lower() == 'weapon' then
                xPlayer.addWeapon(item, 90)
            else
                xPlayer.addInventoryItem(item, count)
            end
        end
    end

    function GetPlayerNameFunction(source)
        local name
        if Config.SteamName then
            name = GetPlayerName(source) or 'No Data'
        else
            local xPlayer = GETPFI(source)
            name = xPlayer.getName() or 'No Data'
        end
        return name
    end

    function GetPlayerJob(source)
        local xPlayer = GETPFI(source)
        return xPlayer.job.name
    end

    function CreateCoreJob(name, label, grades)
        Core.CreateJob(name, label, grades)
    end

    function SetCoreJob(source, job, grade)
        local xPlayer = GETPFI(source)
        xPlayer.setJob(job, grade)
    end

    function SetCoreJobOffline(identifier, job, grade)
        MySQL.update('UPDATE users SET job = ?, job_grade = ? WHERE identifier = ?', {job, grade, identifier})
    end

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

    Core = exports['qb-core']:GetCoreObject()
    
    RESCB = Core.Functions.CreateCallback
    GETPFI = Core.Functions.GetPlayer
    RUI = Core.Functions.CreateUseableItem
    SetJobEvent = 'QBCore:Server:SetGang'
    onPlayerDeath = GetResourceState("brutal_ambulancejob") == "started" and 'onPlayerDeath' or 'hospital:server:SetDeathStatus'
    UsersDataTable = 'players'
    UserIdentifierValue = 'citizenid'

    function GetIdentifier(source)
        local xPlayer = GETPFI(source)
        while xPlayer == nil do
            Citizen.Wait(1000)
            xPlayer = GETPFI(source) 
        end
        return xPlayer.PlayerData.citizenid
    end

    function GetPlayerByIdentifier(identifier)
        return Core.Functions.GetPlayerByCitizenId(identifier)
    end

    function GetAccountMoney(source, account)
        local xPlayer = GETPFI(source)
        if account == 'bank' then
            return xPlayer.PlayerData.money.bank
        elseif account == 'money' then
            return xPlayer.PlayerData.money.cash
        end
    end

    function AddMoneyFunction(source, account, amount)
        local xPlayer = GETPFI(source)
        if account == 'bank' then
            xPlayer.Functions.AddMoney('bank', amount)
        elseif account == 'money' then
            xPlayer.Functions.AddMoney('cash', amount)
        end
    end

    function RemoveAccountMoney(source, account, amount)
        local xPlayer = GETPFI(source)
        if account == 'bank' then
            xPlayer.Functions.RemoveMoney('bank', amount)
        elseif account == 'money' then
            xPlayer.Functions.RemoveMoney('cash', amount)
        end
    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 RemoveItem(source, item, amount)
        local xPlayer = GETPFI(source)
        xPlayer.Functions.RemoveItem(item, amount)
    end

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

    function GetPlayerNameFunction(source)
        local name
        if Config.SteamName then
            name = GetPlayerName(source)
        else
            local xPlayer = GETPFI(source)
            name = xPlayer.PlayerData.charinfo.firstname..' '..xPlayer.PlayerData.charinfo.lastname
        end
        return name
    end

    function GetPlayerJob(source)
        local xPlayer = GETPFI(source)
        return xPlayer.PlayerData.gang.name
    end

    function CreateCoreJob(name, label, grades)
        Core.Functions.AddGang(name, 
        {
            label = label,
            grades = grades,
        })
    end

    function UpdateCoreJob(name, label, grades)
        Core.Functions.UpdateGang(name, {
            label = label,
            grades = grades,
        })
    end

    function RemoveCoreJob(name)
        Core.Functions.RemoveGang(name)
    end

    function SetCoreJob(source, job, grade)
        local xPlayer = GETPFI(source)
        xPlayer.Functions.SetGang(job, grade)
    end

    function SetCoreJobOffline(identifier, job)
        local joblabel = "None"
        if Gangs[job] ~= nil and Gangs[job].label ~= nil then
            joblabel = Gangs[job].label
        end

        MySQL.update('UPDATE players SET gang = ? WHERE citizenid = ?', {json.encode({grade = {level = 0, name = "Member"}, name = job, isboss = false, label = joblabel}), identifier})
    end
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'
    ReviveEvent = 'esx_ambulancejob:revive'
    JobUpdateEvent = 'esx:setJob'
    TSCB = Core.TriggerServerCallback

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

    function GetClosestPlayerFunction()
        if not Config.ClosestDistanceIssue then
            return Core.Game.GetClosestPlayer()
        else
            local pedCoords = GetEntityCoords(PlayerPedId())
            local closestPlayer, _, targetCoords = lib.getClosestPlayer(pedCoords, 100.0)
            local distance = 100.0
            if closestPlayer ~= nil then
                distance = #(pedCoords - targetCoords)
            end

            return closestPlayer, distance
        end
    end

    function GetPlayersFunction()
        return Core.Game.GetPlayers()
    end

    function GetVehiclePropertiesFunction(vehicle)
        return Core.Game.GetVehicleProperties(vehicle)
    end

    function SetVehiclePropertiesFunction(vehicle, properties)
        return Core.Game.SetVehicleProperties(vehicle, properties)
    end

    function GetClosestVehicleFunction(coords, modelFilter)
        return Core.Game.GetClosestVehicle(coords, modelFilter)
    end

elseif Config['Core']:upper() == 'QBCORE' then
    Core = exports['qb-core']:GetCoreObject()

    LoadedEvent = 'QBCore:Client:OnPlayerLoaded'
    ReviveEvent = 'hospital:client:Revive'
    JobUpdateEvent = 'QBCore:Client:OnGangUpdate'
    TSCB = Core.Functions.TriggerCallback

    function GetPlayerJobDatas()
        return Core.Functions.GetPlayerData().gang
    end

    function GetClosestPlayerFunction()
        return Core.Functions.GetClosestPlayer()
    end

    function GetPlayersFunction()
        return Core.Functions.GetPlayers()
    end

    function GetVehiclePropertiesFunction(vehicle)
        return Core.Functions.GetVehicleProperties(vehicle)
    end

    function SetVehiclePropertiesFunction(vehicle, properties)
        return Core.Functions.SetVehicleProperties(vehicle, properties)
    end

    function GetClosestVehicleFunction(coords, modelFilter)
        return Core.Functions.GetClosestVehicle(coords, modelFilter)
    end
    
end
server-core.lua
Core = nil

if Config['Core']:upper() == 'ESX' then
    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
    SetJobEvent = 'esx:setJob'
    onPlayerDeath = 'esx:onPlayerDeath'
    UsersDataTable = 'users'
    UserIdentifierValue = 'identifier'

    function GetIdentifier(source)
        local xPlayer = GETPFI(source)
        while xPlayer == nil do
            Citizen.Wait(1000)
            xPlayer = GETPFI(source) 
        end
        return xPlayer.identifier
    end

    function GetPlayerByIdentifier(identifier)
        return Core.GetPlayerFromIdentifier(identifier)
    end

    function GetAccountMoney(source,account)
        local xPlayer = GETPFI(source)
        if account == 'bank' then
            return xPlayer.getAccount(account).money
        elseif account == 'money' then
            return xPlayer.getMoney()
        end
    end

    function AddMoneyFunction(source, account, amount)
        local xPlayer = GETPFI(source)
        if account == 'bank' then
            xPlayer.addAccountMoney('bank', amount)
        elseif account == 'money' then
            xPlayer.addMoney(amount)
        end
    end

    function RemoveAccountMoney(source, account, amount)
        local xPlayer = GETPFI(source)
        if account == 'bank' then
            xPlayer.removeAccountMoney('bank', amount)
        elseif account == 'money' then
            xPlayer.removeMoney(amount)
        end
    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 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 AddItem(source, item, count, info)
        local xPlayer = GETPFI(source)
        if _esx_ == 'new' then
            xPlayer.addInventoryItem(item, count, info)
        else
            if string.sub(item, 0, 6):lower() == 'weapon' then
                xPlayer.addWeapon(item, 90)
            else
                xPlayer.addInventoryItem(item, count)
            end
        end
    end

    function GetPlayerNameFunction(source)
        local name
        if Config.SteamName then
            name = GetPlayerName(source) or 'No Data'
        else
            local xPlayer = GETPFI(source)
            name = xPlayer.getName() or 'No Data'
        end
        return name
    end

    function GetPlayerJob(source)
        local xPlayer = GETPFI(source)
        return xPlayer.job.name
    end

    function CreateCoreJob(name, label, grades)
        Core.CreateJob(name, label, grades)
    end

    function SetCoreJob(source, job, grade)
        local xPlayer = GETPFI(source)
        xPlayer.setJob(job, grade)
    end

    function SetCoreJobOffline(identifier, job, grade)
        MySQL.update('UPDATE users SET job = ?, job_grade = ? WHERE identifier = ?', {job, grade, identifier})
    end

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

    Core = exports['qb-core']:GetCoreObject()
    
    RESCB = Core.Functions.CreateCallback
    GETPFI = Core.Functions.GetPlayer
    RUI = Core.Functions.CreateUseableItem
    SetJobEvent = 'QBCore:Server:SetGang'
    onPlayerDeath = GetResourceState("brutal_ambulancejob") == "started" and 'onPlayerDeath' or 'hospital:server:SetDeathStatus'
    UsersDataTable = 'players'
    UserIdentifierValue = 'citizenid'

    function GetIdentifier(source)
        local xPlayer = GETPFI(source)
        while xPlayer == nil do
            Citizen.Wait(1000)
            xPlayer = GETPFI(source) 
        end
        return xPlayer.PlayerData.citizenid
    end

    function GetPlayerByIdentifier(identifier)
        return Core.Functions.GetPlayerByCitizenId(identifier)
    end

    function GetAccountMoney(source, account)
        local xPlayer = GETPFI(source)
        if account == 'bank' then
            return xPlayer.PlayerData.money.bank
        elseif account == 'money' then
            return xPlayer.PlayerData.money.cash
        end
    end

    function AddMoneyFunction(source, account, amount)
        local xPlayer = GETPFI(source)
        if account == 'bank' then
            xPlayer.Functions.AddMoney('bank', amount)
        elseif account == 'money' then
            xPlayer.Functions.AddMoney('cash', amount)
        end
    end

    function RemoveAccountMoney(source, account, amount)
        local xPlayer = GETPFI(source)
        if account == 'bank' then
            xPlayer.Functions.RemoveMoney('bank', amount)
        elseif account == 'money' then
            xPlayer.Functions.RemoveMoney('cash', amount)
        end
    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 RemoveItem(source, item, amount)
        local xPlayer = GETPFI(source)
        xPlayer.Functions.RemoveItem(item, amount)
    end

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

    function GetPlayerNameFunction(source)
        local name
        if Config.SteamName then
            name = GetPlayerName(source)
        else
            local xPlayer = GETPFI(source)
            name = xPlayer.PlayerData.charinfo.firstname..' '..xPlayer.PlayerData.charinfo.lastname
        end
        return name
    end

    function GetPlayerJob(source)
        local xPlayer = GETPFI(source)
        return xPlayer.PlayerData.gang.name
    end

    function CreateCoreJob(name, label, grades)
        Core.Functions.AddGang(name, 
        {
            label = label,
            grades = grades,
        })
    end

    function UpdateCoreJob(name, label, grades)
        Core.Functions.UpdateGang(name, {
            label = label,
            grades = grades,
        })
    end

    function RemoveCoreJob(name)
        Core.Functions.RemoveGang(name)
    end

    function SetCoreJob(source, job, grade)
        local xPlayer = GETPFI(source)
        xPlayer.Functions.SetGang(job, grade)
    end

    function SetCoreJobOffline(identifier, job)
        local joblabel = "None"
        if Gangs[job] ~= nil and Gangs[job].label ~= nil then
            joblabel = Gangs[job].label
        end

        MySQL.update('UPDATE players SET gang = ? WHERE citizenid = ?', {json.encode({grade = {level = 0, name = "Member"}, name = job, isboss = false, label = joblabel}), identifier})
    end
end
PreviousExecutionsNextInstallation guide

Last updated 5 months ago

Was this helpful?

🎯
Page cover image