tarek-alhassan avatar image
tarek-alhassan asked

Saving simple strings and integers to PlayFab?

Hello. I already built a game that uses PlayerPrefs strings and integers to store the player's unlocked characters, coins and high score. Lately, I've been trying to link my game with FaceBook and PlayFab so it could support cross platform. I looked everywhere and the concept of using PlayFab's characters and currency thing seemed overcomplicated to me, as I am a beginner and I couldn't find any detailed tutorial on how to implement these things to my game. So my question is: How can save these PlayerPrefs (string and ints) for each player on PlayFab?

Player DataIn-Game EconomyCharacters
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

1 Answer

brendan avatar image
brendan answered

You can save strings to player data, though I would recommend aggregating small pieces of data into fewer, larger strings - JSON format is usually best for this. Here's a tutorial on using our player data system:

For the currencies and economy, there's a section of our tutorials page dedicated to these topics, here: I would start by setting up your virtual currencies (, and then your in-game catalog ( For a pre-existing game where you want to give the player all the VC and items they already have, you'll need to stage that out over time (at least, for the inventory). Ideally, you would use Cloud Script for this, so that you can put in some checks to at least try to prevent the most egregious cheating of your game.

So what you could do, for example, is first check to see if the player already has their currency and inventory set up. If not, use this API to set up their currency:

And then write all the items they have in inventory to player internal data. Then, have the client periodically (every 20-30 seconds) call to a Cloud Script that reads from internal data, grants 20 or so items, and updates the player internal data to remove those items from the "to add" list.

10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

tarek-alhassan avatar image tarek-alhassan commented ·

Hello @Brendan. Thank you very much for your detailed answer, I really appreciate your help. To be honest, I have some few things that I need to clarify. What I am trying to create at the moment is a way to know if the player has signed in previously and his account exists or not. Upon sign in, the game will check if the account already exists by checking a string that should be given to every new account created. So if that account has that string, the account already exists. Else, give the player that string. I am using this way to know how to sync the characters that are in my game (in the case the player didn't sign up immediately and unlocked some characters). And based on the links and tutorials that you provided, I found that UpdateUserInternalData() is the correct way to do this (Correct me if I am wrong).

And the other question is: Does using UpdateUserInternalData() store the data in a JSON file? and if yes, is it a separate file for each player? and is there a way to access this file (in case something happens and I need to check the Player's data)?

Again, thank you very much for your help!

0 Likes 0 ·
brendan avatar image brendan ♦♦ tarek-alhassan commented ·

Player internal data is a distinct per user, though it's string/string key/value pair data right now. But depending on the specifics of what you mean concerning first sign-in there may be ways to accomplish that using PlayStream Rules. Bear in mind that the first time an account is created in any game, you'll get the player_created event, and the first time a player signs into a particular title, you'll get the player_added_title event.

0 Likes 0 ·

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Error rendering WebPanel (widgets/consolidation-widget.ftl): org.hibernate.hql.internal.ast.QuerySyntaxException: AvailableConsolidation is not mapped [from AvailableConsolidation up where up.node = :node]