> For the complete documentation index, see [llms.txt](https://docs.msquared.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.msquared.io/creation/unreal-development/features-and-tutorials/accounts/account-balances.md).

# \[Deprecated] Account Balances

{% hint style="danger" %}
Due for Removal, please speak to support for further info.

**09/06/2025:** MSquared will no longer be supporting "currency" as a concept. If you want similar functionality, it will need to be implemented via an alternative service, e.g. the [KV Store](/creation/unreal-development/features-and-tutorials/online-services/kv-store-service.md).
{% endhint %}

## Overview

The inventory system supports items being assigned a quantity. By reading and writing the quantity number you can implement various in-game balances and currencies, and things like:

* Metagame numbers such as XP, Ranks, High Scores
* Consumables, such as potions
* Achievement progress amounts

## Integration

The currency system currently supports two types of currencies, online and offline. Online currencies persist in a player's Collection, and in turn persist across deployments and events. Offline currencies doesn't interact with the user's collection and so don't persist, but can be used for transient currencies or point systems.

### Creating a currency

To create a currency, create a new Data Asset of type `J_CurrencyTypePrimaryAsset`. Once that has been created, open it up and fill in the details. If you want this to be an "online" currency then tick the `IsCollectionCurrency` check box. You will also need to fill in `DataSourceId` and `ObjectId` - refer to the Online Mode section to see where to get those details. If you are making an offline currency then leave these two blank, and `IsCollectionCurrency` unselected.

<figure><img src="https://1456550285-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FoWTlPaoHd1McSakqMigu%2Fuploads%2Fgit-blob-22f37e872879600dfb8b7ec43d59f1a2ebc9e068%2Fimage.png?alt=media" alt=""><figcaption></figcaption></figure>

### **Online Mode**

Online currencies require an object definition to be created in the back end. If your project supports it, you may be able to create a user collection object yourself using the web UI - simply add a new object into a non-public collection with some kind of asset (usually a thumbnail image), and ensure it has a currency property by entering `{ "currency" : "" }` in the Properties section.

<figure><img src="https://1456550285-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FoWTlPaoHd1McSakqMigu%2Fuploads%2Fgit-blob-59f739e2cb842de910cb9bf34a27e7a444e639eb%2Fimage.png?alt=media" alt=""><figcaption><p>Adding a new Currency object</p></figcaption></figure>

The `DataSourceId` and `ObjectId` for your object can be seen in the Datasource view as shown:

<figure><img src="https://1456550285-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FoWTlPaoHd1McSakqMigu%2Fuploads%2Fgit-blob-388611640b8aa2707c9c72a1eefba29e7ffeaf53%2Fimage.png?alt=media" alt=""><figcaption><p>Datasource and Object IDs</p></figcaption></figure>

Alternatively, contact a member of the platform team and a Support Engineer can create the object for you. Once they have created the object definition, they will be able to inform you of the `DataSourceId` and `ObjectId` to use.

Using an online currency also requires that user collections are enabled on the server. Ensure that the following `game` live config value is enabled: `UserCollection.EnabledOnServers`

### Offline Mode

For an offline currency this isn't required - simply fill in the standard details in the data asset and you can start using it.

## How to enable

Your player Morpheus blueprint should already inherit from `BPM_M2_BasePlayerCharacter`. In this case it will already have a wallet component attached.

To make sure the balance is updated, you will need to turn on User Collection Polling using the [Live Config](/creation/unreal-development/features-and-tutorials/live-config.md) setting `UserCollection.Polling.ClientEnabled` - see [here](/creation/unreal-development/features-and-tutorials/live-config/overriding-default-live-config-settings.md) how to overrride this.

To interact with the players wallet you use the `J_CurrencySubsystem`. This has functions to get, give and take currency from the player's wallet. Examples of each of those can be seen below. Getting a currency can be done on a client, but giving or taking must be done from the server.

{% hint style="warning" %}
**Note**: Currently due to limitation of the collection system, getting a currency can only be done on the client if it is an online currency. You may receive a message saying "`User collection service is invalid`" when you run the editor in offline mode.
{% endhint %}

<figure><img src="https://1456550285-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FoWTlPaoHd1McSakqMigu%2Fuploads%2Fgit-blob-3b087b6932daa99c4052f61fbcbf9e4b3687ac26%2Fimage.png?alt=media" alt=""><figcaption><p>Example of getting a currency</p></figcaption></figure>

<figure><img src="https://1456550285-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FoWTlPaoHd1McSakqMigu%2Fuploads%2Fgit-blob-d79009b89baa2c016254435886e601157d965cc5%2Fimage.png?alt=media" alt=""><figcaption><p>Example of giving currency</p></figcaption></figure>

<figure><img src="https://1456550285-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FoWTlPaoHd1McSakqMigu%2Fuploads%2Fgit-blob-e1885bb7d1b7afaeb4686446097901642af81e82%2Fimage.png?alt=media" alt=""><figcaption><p>Example of taking currency</p></figcaption></figure>
