GameSalad & Playfab: Currency

Posted by

In this blog entry, I’ll show you how to retrieve virtual currency from Playfab. Up to this point, I had been connecting to the Playfab automatically. I needed a place to store the data that is being returned by Playfab and also to allow the app to be able to login to the service that is appropriate (a future change).

First, configure your virtual currency in Playfab and assign some to your test user:

Screen Shot 2020-04-15 at 11.19.00 PM

At the top of the latest integration file (attached)  change the currency code to your currency code. The “UserVirtualCurrency.” portion you need to keep but you will need to change the “ST” portion of the string.

“playfab” : {

type:“serviceCall”,

tableColumnsValues:[1],

tableRowValues:[“UserVirtualCurrency.ST”]

}

I couple of things to note is that you can put any field that is currently returned with my integration (more on this la at the bottom) with Playfab and you can also include multiple virtual currencies like this:

“playfab” : {

type:“serviceCall”,

tableColumnsValues:[1],

tableRowValues:[“UserVirtualCurrency.ST”, “”UserVirtualCurrency.MO”]

}

Now in GameSalad create a table and name it “playfab” (by now you should have guessed this). Just 1 column is fine and the number of rows doesn’t matter. You don’t need to fill any values or names. The call will overwrite them all. They are filled-in in the picture for illustration purposes only.

Screen Shot 2020-04-15 at 10.50.22 PM

When you want to log into Playfab call the score function with the Playfab table:

Screen Shot 2020-04-15 at 10.52.07 PM

Now the value should show up in the field and you can use it in your game.

Screen Shot 2020-04-15 at 10.57.24 PM

Before I end this I want to mention what is configurable (optional read). At the top of the integration file, you can now specify what data is pulled with the Playfab request:

var infoRequestParameters = {

    GetUserData:true,

    GetUserVirtualCurrency:true

}

At this moment, those are the only two that I am using. If you have read all the post you will realize that the “GetUserData” is where I am storing the game parameters. But if you want those parameters returned in the Playfab table all you need to do is add it to the mapping. For example, if I wanted to pull the avatar parameter into the table,  I would add it to the tableRowValues and it would be available in the Playfab table with a row name of “UserData.avatar.Value.”

“playfab” : {

type:“serviceCall”,

tableColumnsValues:[1],

tableRowValues:[“UserVirtualCurrency.ST”,”UserData.avatar.Value”]

}

You can also add any request type that is supported by Playfab into the infoRequestParameters table and then any field that is returned by that request. I have not tested all the permutation but it should work.

Anyway. that is all I have for now. Stay safe and make some great games.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.