# 🏷️ Placeholder Currencies

## Placeholder Currencies

A Placeholder currency lets a shop charge in anything another plugin keeps a number for, such as a DeluxeMenus meta value or a token plugin with no economy hook of its own. The balance is read from a placeholder, and the money is moved by console commands you write. This is a Premium feature and needs [PlaceholderAPI](https://modrinth.com/plugin/placeholderapi).

<figure><img src="../../.gitbook/assets/placeholder-currencies/placeholder-currencies.png" alt="" width="563"><figcaption><p>Currencies (Souls)</p></figcaption></figure>

On Lite, Placeholder currencies are not loaded and the console says so once.

## Creating One

Open **Editor > Settings > Currencies** and click **New Placeholder Currency**, or pick the Placeholder type on a shop, category or item and right-click it. Each new currency gets the next free id, `custom_1`, `custom_2` and so on, with Tokens as its display name, and opens straight into its settings. Any number can be made, and each one shows up by its display name in the currency picker of a shop, category or item.

<figure><img src="../../.gitbook/assets/placeholder-currencies/creating-one.png" alt="" width="563"><figcaption><p>Currencies (New Placeholder Currency)</p></figcaption></figure>

Right-clicking a placeholder currency in the currency picker of a shop, category or item opens its settings, with the Currency Format beside them. The Currency Format is how prices are written, such as `%amount% Tokens`.

## Display Name

The name shown after prices, like 50 Tokens, and in the currency picker. It cannot be empty.

<figure><img src="../../.gitbook/assets/placeholder-currencies/display-name.png" alt="" width="563"><figcaption><p>Placeholder Currency (Display Name)</p></figcaption></figure>

## Balance Placeholder

The placeholder that holds a player's balance, such as `%deluxemenus_meta_mynewint_INTEGER_1%`. It has to return a number. Commas are ignored and `k`, `m`, `b` and `t` suffixes are read, but anything else that is not a number leaves the player unable to afford anything.

<figure><img src="../../.gitbook/assets/placeholder-currencies/balance-placeholder.png" alt="" width="563"><figcaption><p>Placeholder Currency (Balance Placeholder)</p></figcaption></figure>

An empty or wrong placeholder is not checked: the currency stays usable while PlaceholderAPI is installed, and every player reads as having nothing.

## Buy Command

The console command that runs when a player pays in this currency, taking the price from them. For example `dm meta %player% subtract mynewint INTEGER %amount_int%`.

<figure><img src="../../.gitbook/assets/placeholder-currencies/buy-command.png" alt="" width="563"><figcaption><p>Placeholder Currency (Buy Command)</p></figcaption></figure>

## Sell Command

The console command that runs when a player is paid in this currency, giving them the price. For example `dm meta %player% add mynewint INTEGER %amount_int%`.

<figure><img src="../../.gitbook/assets/placeholder-currencies/sell-command.png" alt="" width="563"><figcaption><p>Placeholder Currency (Sell Command)</p></figcaption></figure>

| Placeholder | Description |
| --- | --- |
| %player% | The player's name. |
| %amount% | The price, with decimals. |
| %amount\_int% | The price rounded up to a whole number. |

> **Warning:**
The plugin cannot tell whether a command worked. Test both commands on yourself before pricing a shop in the currency, since a typo takes nothing or pays nothing while the purchase or sale still goes through.

## In the Shop File

The whole currency is written into the block of the shop, category or item that uses it.

```yaml
currency:
  type: PLACEHOLDER
  identifier: tokens
  placeholder:
    display-name: Tokens
    balance: '%deluxemenus_meta_mynewint_INTEGER_1%'
    buy: 'dm meta %player% subtract mynewint INTEGER %amount_int%'
    sell: 'dm meta %player% add mynewint INTEGER %amount_int%'
```

When several blocks share an identifier, the first one read defines the currency. Editing it in-game rewrites every block that uses it.

Source: https://www.phoenixplugins.com/docs/phoenix-shop/main-features/currencies/placeholder-currencies