Account Balances

Experimental - Customers are encouraged to test and use this feature in their experiences, but it may still require some additional support

Overview

The ability to read and write to things in your collection that can be polled for a number, this can be used for Balances and Currencies and could also be used for the following: - Metagame such as XP, Ranks, High Scores - Consumables, such as potions - Achievement amounts

Integration

The currency system currently supports two types of currencies, the online and the offline. Any online currencies should persist in a players collection and in turn persist over deployments and events. Offline mode doesn't need to interact with the users collection and so does not persist but can be used for one time currencies or point systems.

Creating a currency

Creating a currency is simple, you just need to create a new asset type in the PDAs/Currencies folder, in a world-builder project if it doesn't exist then create that folder too.

Once that has been created you can open this up and fill in the details that you want. 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 just leave those 3 things blank.

Online Mode

For a currency to be online we need to setup the object definition in the back end. This object needs to have a "Currency" property. This can be done by contacting a member of the platform team and a Support Engineer create the object for you. Once they have created the object definition, they will be able to inform you what DataSourceId and ObjectId to use.

Alternatively, if your project supports it, you may be able to create a user collection object yourself using the web UI. Again, you need to ensure this object has "Currency" as a property. The UID for this object can be obtained by selecting the newly created object in your collection and then looking at the pages web URL. The URL should have a suffix in this form: sFET8JW36TKbJvB1hzbW/27dMD0VZeCPqzrDnCmI8. The DataSourceId is the first half of the string before the "/" and the ObjectId is the second half of the string.

Offline Mode

For an offline currency there isn't much else to it just set it up as above and you should start being able to start using it!

How to enable

By default if you inherit from the BPM_M2_BasePlayerCharacter your player will already have a wallet component attached to them.

To make sure the balance is updated, you will need to turn on User Collection Polling using the Live Config setting UserCollection.Polling.ClientEnabled, see here how to overrride this.

To interact with the players wallet you will want to go through the J_CurrencySubsystem this will give you everything you need to, get, give and take currency from the players 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.

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.

Last updated