QBOX

if you are going to do this make sure that all players have a cash value of 0, if players have a cash value higher than 0 set them all to 0

  1. Open qbx_core/server/player.lua file

  2. Find function self.Functions.AddMoney(moneytype, amount, reason) function

  3. Replace the function with the following

function self.Functions.AddMoney(moneytype, amount, reason)
    reason = reason or 'unknown'
    amount = qbx.math.round(tonumber(amount) --[[@as number]])
    if amount < 0 then return false end
    if not self.PlayerData.money[moneytype] then return false end
    if moneytype == "cash" and self.Offline then return false end
    self.PlayerData.money[moneytype] = self.PlayerData.money[moneytype] + amount
    if not self.Offline then
        if moneytype == "cash" then
            exports["tgiann-inventory"]:AddItem(self.PlayerData.source, "money_item", amount)
        end

        self.Functions.UpdatePlayerData()
        local tags = amount > 100000 and config.logging.role or nil
        local resource = GetInvokingResource() or cache.resource
        logger.log({
            source = resource,
            webhook = config.logging.webhook['playermoney'],
            event = 'AddMoney',
            color = 'lightgreen',
            tags = tags,
            message = ('**%s (citizenid: %s | id: %s)** $%s (%s) added, new %s balance: $%s reason: %s'):format(GetPlayerName(self.PlayerData.source), self.PlayerData.citizenid, self.PlayerData.source, amount, moneytype, moneytype, self.PlayerData.money[moneytype], reason),
            --oxLibTags = ('script:%s,playerName:%s,citizenId:%s,playerSource:%s,amount:%s,moneyType:%s,newBalance:%s,reason:%s'):format(resource, GetPlayerName(self.PlayerData.source), self.PlayerData.citizenid, self.PlayerData.source, amount, moneytype, self.PlayerData.money[moneytype], reason)
        })
        emitMoneyEvents(moneytype, amount, 'add', false, reason)
    end

    return true
end
  1. Find function self.Functions.RemoveMoney(moneytype, amount, reason) function

  2. Replace the function with the following

function self.Functions.RemoveMoney(moneytype, amount, reason)
    reason = reason or 'unknown'
    amount = qbx.math.round(tonumber(amount) --[[@as number]])
    if amount < 0 then return false end
    if not self.PlayerData.money[moneytype] then return false end
    if moneytype == "cash" and self.Offline then return false end
    for _, mtype in pairs(config.money.dontAllowMinus) do
        if mtype == moneytype then
            if (self.PlayerData.money[moneytype] - amount) < 0 then
                return false
            end
        end
    end
    self.PlayerData.money[moneytype] = self.PlayerData.money[moneytype] - amount
    if moneytype == "cash" then
        exports["tgiann-inventory"]:RemoveItem(self.PlayerData.source, "money_item", amount)
    end

    if not self.Offline then
        self.Functions.UpdatePlayerData()
        local tags = amount > 100000 and config.logging.role or nil
        local resource = GetInvokingResource() or cache.resource
        logger.log({
            source = resource,
            webhook = config.logging.webhook['playermoney'],
            event = 'RemoveMoney',
            color = 'red',
            tags = tags,
            message = ('** %s (citizenid: %s | id: %s)** $%s (%s) removed, new %s balance: $%s reason: %s'):format(GetPlayerName(self.PlayerData.source), self.PlayerData.citizenid, self.PlayerData.source, amount, moneytype, moneytype, self.PlayerData.money[moneytype], reason),
            --oxLibTags = ('script:%s,playerName:%s,citizenId:%s,playerSource:%s,amount:%s,moneyType:%s,newBalance:%s,reason:%s'):format(resource, GetPlayerName(self.PlayerData.source), self.PlayerData.citizenid, self.PlayerData.source, amount, moneytype, self.PlayerData.money[moneytype], reason)
        })
        emitMoneyEvents(moneytype, amount, 'remove', true, reason)
    end

    return true
end
  1. Find function self.Functions.SetMoney(moneytype, amount, reason) function

  2. Replace the function with the following

function self.Functions.SetMoney(moneytype, amount, reason, forInventory)
    reason = reason or 'unknown'
    amount = qbx.math.round(tonumber(amount) --[[@as number]])
    if amount < 0 then return false end
    if not self.PlayerData.money[moneytype] then return false end
    if moneytype == "cash" and self.Offline then return end
    local difference = amount - self.PlayerData.money[moneytype]
    self.PlayerData.money[moneytype] = amount

    if moneytype == "cash" and not forInventory then
        local moneyAmount = exports["tgiann-inventory"]:GetItemByName(self.PlayerData.source, "money_item").amount
        if moneyAmount > 0 then
            exports["tgiann-inventory"]:RemoveItem(self.PlayerData.source, "money_item", moneyAmount)
        end
        exports["tgiann-inventory"]:AddItem(self.PlayerData.source, "money_item", amount)
    end

    if not self.Offline then
        self.Functions.UpdatePlayerData()
        local dirChange = difference < 0 and 'removed' or 'added'
        local absDifference = math.abs(difference)
        local tags = absDifference > 50000 and config.logging.role or {}
        local resource = GetInvokingResource() or cache.resource
        logger.log({
            source = resource,
            webhook = config.logging.webhook['playermoney'],
            event = 'SetMoney',
            color = difference < 0 and 'red' or 'green',
            tags = tags,
            message = ('**%s (citizenid: %s | id: %s)** $%s (%s) %s, new %s balance: $%s reason: %s'):format(GetPlayerName(self.PlayerData.source), self.PlayerData.citizenid, self.PlayerData.source, absDifference, moneytype, dirChange, moneytype, self.PlayerData.money[moneytype], reason),
            --oxLibTags = ('script:%s,playerName:%s,citizenId:%s,playerSource:%s,amount:%s,moneyType:%s,newBalance:%s,reason:%s,direction:%s'):format(resource, GetPlayerName(self.PlayerData.source), self.PlayerData.citizenid, self.PlayerData.source, absDifference, moneytype, self.PlayerData.money[moneytype], reason, dirChange)
        })
        emitMoneyEvents(moneytype, absDifference, 'set', difference < 0, reason)
    end

    return true
end
  1. Find local function emitMoneyEvents(moneytype, amount, actionType, direction, reason) function

  2. Replace the function with the following

local function emitMoneyEvents(moneytype, amount, actionType, direction, reason)
    TriggerClientEvent('hud:client:OnMoneyChange', self.PlayerData.source, moneytype, amount, direction)
    TriggerClientEvent('QBCore:Client:OnMoneyChange', self.PlayerData.source, moneytype, amount, actionType, reason)
    TriggerEvent('QBCore:Server:OnMoneyChange', self.PlayerData.source, moneytype, amount, actionType, reason)
    if moneytype == 'bank' and actionType == 'remove' then
        TriggerClientEvent('qb-phone:client:RemoveBankMoney', self.PlayerData.source, amount)
    end
end
  1. Add the following item to the itemlist

money_item = { name = 'money_item', label = 'Money', weight = 0, type = 'item', image = 'money.webp', unique = false, useable = false, shouldClose = false, description = 'Green Paper' },

Last updated