Skip to main content

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.


Step 1: Add Custom Currency Logic

To integrate a new currency, modify the payForItem function in the following file:

config/code/sv_functions.lua

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

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.

Step 2: Add an Icon for Your Currency

Next, you need to assign an icon to your new currency. Go to the locales file:

config/locales

Find the currencyIcons section and add an entry for your new currency with the emoji of your choice. Here's how it should look:

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.

Step 3: Use Your Custom Currency in Configuration

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

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.