Activate Multi Card Mode

Replace the self.removeAccountMoney function in es_extended/server/classes/player.lua with:

for new versions: since 1.11.0

function self.removeAccountMoney(accountName, money, reason)
    reason = reason or "Unknown"
    if not tonumber(money) then
        --print(("[^1ERROR^7] Tried To Set Account ^5%s^0 For Player ^5%s^0 To An Invalid Number -> ^5%s^7"):format(accountName, self.playerId, money))
        return
    end
    if money > 0 then
        local account = self.getAccount(accountName)

        if account then
            money = account.round and ESX.Math.Round(money) or money
            
            if accountName == "bank" and self.accounts[account.index].money < money then
                --print(("^3[Banking]^7 ESX bank insufficient for player %s, attempting custom bank withdrawal"):format(self.source))
                
                local success = exports['S-Banking']:removeFundsFromAccount(self.source, money)
                
                if success then
                    TriggerClientEvent('S-Banking:notify', self.source, 'success', 
                        'Payment of $' .. money .. ' processed from your custom bank account')
                    exports['S-Banking']:LogWebhook("ESX Payment Fallback", 
                        "Payment of $" .. money .. " processed from custom bank account because ESX bank was insufficient", 
                        self.source)
                    return true
                else
                    TriggerClientEvent('S-Banking:notify', self.source, 'error', 'Insufficient funds in all accounts')
                    return false
                end
            end
            
            if self.accounts[account.index].money - money > self.accounts[account.index].money then
                --print(("[^1ERROR^7] Tried To Underflow Account ^5%s^0 For Player ^5%s^0!"):format(accountName, self.playerId))
                return
            end
            self.accounts[account.index].money = self.accounts[account.index].money - money

            self.triggerEvent("esx:setAccountMoney", account)
            _TriggerEvent("esx:removeAccountMoney", self.source, accountName, money, reason)
        else
            --print(("[^1ERROR^7] Tried To Set Add To Invalid Account ^5%s^0 For Player ^5%s^0!"):format(accountName, self.playerId))
        end
    else
        --print(("[^1ERROR^7] Tried To Set Account ^5%s^0 For Player ^5%s^0 To An Invalid Number -> ^5%s^7"):format(accountName, self.playerId, money))
    end
end

or for older versions like 1.10.7

function self.removeAccountMoney(accountName, money, reason)
    reason = reason or "Unknown"
    if not tonumber(money) then
        --print(("[^1ERROR^7] Tried To Set Account ^5%s^0 For Player ^5%s^0 To An Invalid Number -> ^5%s^7"):format(accountName, self.playerId, money))
        return
    end
    if money > 0 then
        local account = self.getAccount(accountName)

        if account then
            money = account.round and ESX.Math.Round(money) or money
            
            if accountName == "bank" and self.accounts[account.index].money < money then
                --print(("^3[Banking]^7 ESX bank insufficient for player %s, attempting custom bank withdrawal"):format(self.source))
                
                local success = exports['S-Banking']:removeFundsFromAccount(self.source, money)
                
                if success then
                    TriggerClientEvent('S-Banking:notify', self.source, 'success', 
                        'Payment of $' .. money .. ' processed from your custom bank account')
                    exports['S-Banking']:LogWebhook("ESX Payment Fallback", 
                        "Payment of $" .. money .. " processed from custom bank account because ESX bank was insufficient", 
                        self.source)
                    return true
                else
                    TriggerClientEvent('S-Banking:notify', self.source, 'error', 'Insufficient funds in all accounts')
                    return false
                end
            end
            
            if self.accounts[account.index].money - money > self.accounts[account.index].money then
                --print(("[^1ERROR^7] Tried To Underflow Account ^5%s^0 For Player ^5%s^0!"):format(accountName, self.playerId))
                return
            end
            self.accounts[account.index].money = self.accounts[account.index].money - money

            self.triggerEvent("esx:setAccountMoney", account)
            TriggerEvent("esx:removeAccountMoney", self.source, accountName, money, reason)
        else
            --print(("[^1ERROR^7] Tried To Set Add To Invalid Account ^5%s^0 For Player ^5%s^0!"):format(accountName, self.playerId))
        end
    else
        --print(("[^1ERROR^7] Tried To Set Account ^5%s^0 For Player ^5%s^0 To An Invalid Number -> ^5%s^7"):format(accountName, self.playerId, money))
    end
end

Last updated