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.