πŸ”₯All scripts on our website are 50% off!πŸ”₯
Logo

Payment Methods

By default, the payment method is by money in the bank (Config.useAccount). This value can be changed to another type of account.

If you need to modify the payment method, for example to use items, you can do it by modifying the functions:

getUserMoney, addUserMoney and removeUserMoney found at the end of config.lua

Customizing Payment Methods

The script uses three core functions to handle all financial transactions:

getUserMoney

This function retrieves the player's current balance. Modify this function to check different account types or item quantities:

function getUserMoney(xPlayer)
    if Config.Framework == "esx" then
        local money = xPlayer.getAccount(Config.useAccount).money
        return money
    elseif Config.Framework == "qb" then
       local money = xPlayer.PlayerData.money[Config.useAccount]
       return money
    end
end

addUserMoney

This function adds money to the player's account. Customize this to give items or add to different accounts:

function addUserMoney(xPlayer, amount)
    if Config.Framework == "esx" then
        xPlayer.addMoney(amount)
    elseif Config.Framework == "qb" then
        xPlayer.Functions.AddMoney(Config.useAccount, amount, "Business")
    end
end

removeUserMoney

This function removes money from the player's account. Modify this to remove items or deduct from different accounts:

function removeUserMoney(xPlayer, amount)
    if Config.Framework == "esx" then
        xPlayer.removeAccountMoney(Config.useAccount, amount)
    elseif Config.Framework == "qb" then
        xPlayer.Functions.RemoveMoney(Config.useAccount, amount, "Business")
    end
end

Example: Using Items Instead of Money

If you want to use items instead of cash for business transactions, you could modify the functions like this:

-- Example: Using a "business_token" item
function getUserMoney(xPlayer)
    if Config.Framework == "esx" then
        local item = xPlayer.getInventoryItem('business_token')
        return item.count
    elseif Config.Framework == "qb" then
        local item = xPlayer.Functions.GetItemByName('business_token')
        return item and item.amount or 0
    end
end

function addUserMoney(xPlayer, amount)
    if Config.Framework == "esx" then
        xPlayer.addInventoryItem('business_token', amount)
    elseif Config.Framework == "qb" then
        xPlayer.Functions.AddItem('business_token', amount)
    end
end

function removeUserMoney(xPlayer, amount)
    if Config.Framework == "esx" then
        xPlayer.removeInventoryItem('business_token', amount)
    elseif Config.Framework == "qb" then
        xPlayer.Functions.RemoveItem('business_token', amount)
    end
end

Always test your custom payment methods thoroughly to ensure they work correctly with all business operations including purchases, sales, stock buying, and worker payments.