Add Currency

The Coinsystem allows for multiple payment types beyond just coins, such as cash and custom currencies. In this guide, we’ll walk through how to add a custom currency to the Coinsystem using **black money** as an example.

Add Custom Currency Logic

Here’s an example of how to add black money as a payment method:

config/code/sv_functions.lua
function payForItem(src, currency, price) 
    if currency == "coins" then 
        return removeCoins(src, price)
    elseif currency == "money" then
        return Sky.FW.RemoveAccountMoney(src, "money", price)
    elseif currency == "black_money" then
        return Sky.FW.RemoveAccountMoney(src, "black_money", price)
    end
    return false
end

In this function:

  • The parameter currency determines which payment method is used.
  • The new logic for black money is added as another conditional check using "black_money".
  • Make sure you use the same currency name consistently throughout your code.

Add an Icon for Your Currency

Next, you need to assign an icon to your new currency. Go to the Locales part of your config file, find the currencyIcons section and add an entry for your new currency with the emoji of your choice. Here's how it should look:

config/config.lua
-- Locales {
currencyIcons = {
    coins = "🪙",
    money = "💵",
    black_money = "💰",
}
  • Ensure that the currency name ("black_money") matches exactly with the name used in your code.
  • You can use any emoji or letter to represent your new currency.

Use Your Custom Currency in Configuration

Now that the logic and icons are in place, you can start using the custom currency in your configuration. For example, if you want a shop item to be purchasable using black money, your configuration should look like this:

config/config.lua
pay = "black_money",

This will ensure that black money is used as the payment type for this particular item.

That’s it! You’ve successfully added a custom currency to the Coinsystem. You can repeat the steps above to add more currencies, adjusting the logic, icon, and configuration accordingly.