Adding more accounts to displayers

In order to add more accounts for displayers to be visible there go to /server/config/player.lua file and find the following code:

Make sure that you already done backend for it!

GetUserWallets = function(source)
    local xPlayer = FrameworkSelected == 'ESX' and ESX.GetPlayerFromId(source) or FrameworkSelected == 'QBCore' and QBCore.Functions.GetPlayer(source) or FrameworkSelected == 'QBOX' and exports['qbox_core']:GetPlayer(source) or false
    local wallets
    if FrameworkSelected == 'ESX' then
        wallets = {
            cash = {
                type = 'cash',
                label = 'Cash',
                text = xPlayer.getAccount('money').money,
                icon = 'fas fa-wallet',
            },
            bank = {
                type = 'bank',
                label = 'Bank',
                text = xPlayer.getAccount('bank').money,
                icon = 'fas fa-credit-card'
            }, 
        }
    elseif FrameworkSelected == 'QBOX' or FrameworkSelected == 'QBCore' then
        wallets = {
            cash = {
                type = 'cash',
                label = 'Cash',
                text = xPlayer.Functions.GetMoney('cash'),
                icon = 'fas fa-wallet',
            },
            bank = {
                type = 'bank',
                label = 'Bank',
                text = xPlayer.Functions.GetMoney('bank'),
                icon = 'fas fa-credit-card'
            }, 
        }
    end
    return wallets
end

We will be doing example on ESX with some crypto coin, here's the revised code for that:

GetUserWallets = function(source)
    local xPlayer = FrameworkSelected == 'ESX' and ESX.GetPlayerFromId(source) or FrameworkSelected == 'QBCore' and QBCore.Functions.GetPlayer(source) or FrameworkSelected == 'QBOX' and exports['qbox_core']:GetPlayer(source) or false
    local wallets
    if FrameworkSelected == 'ESX' then
        wallets = {
            cash = {
                type = 'cash',
                label = 'Cash',
                text = xPlayer.getAccount('money').money,
                icon = 'fas fa-wallet',
            },
            bank = {
                type = 'bank',
                label = 'Bank',
                text = xPlayer.getAccount('bank').money,
                icon = 'fas fa-credit-card'
            },
                --[[
                    Here's the code we've added
                ]]
              
            ['crypto-coin'] = {
                type = 'crypto-coin',
                label = 'Crypto Coin',
                text = xPlayer.getAccount('cryptocoin').money,
                icon = 'fab fa-bitcoin'
            },
        }
    elseif FrameworkSelected == 'QBOX' or FrameworkSelected == 'QBCore' then
        wallets = {
            cash = {
                type = 'cash',
                label = 'Cash',
                text = xPlayer.Functions.GetMoney('cash'),
                icon = 'fas fa-wallet',
            },
            bank = {
                type = 'bank',
                label = 'Bank',
                text = xPlayer.Functions.GetMoney('bank'),
                icon = 'fas fa-credit-card'
            }, 
        }
    end
    return wallets
end

And that's it!

Last updated