question

brendan avatar image
brendan asked

How can I best share player-specific data between players?

What are all the options for sharing player-specific data (saves, configuration info for costumes, etc.) between players in PlayFab?

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

Brendan Vanous
started a topic on Tue, 23 September 2014 at 5:04 PM

There are now three additional ways to share data between players in PlayFab, depending on your games' needs:

Account Data

In order to provide titles with a way for the client to query for information on other players (for example, added context in realtime game sessions), the GetAccountInfo API call has been updated to take an optional PlayFabId, which can be used to specify any other player. Note however that when querying the account information of users other than the locally signed-in user, personally identifying information such as email address is not returned.

User Data

Similarly, user data can now be made readable by other players, so that information stored for one user can be shared across their friends (or anyone else playing your game). To enable this, simply set the Permission property to Public in your call to UpdateUserData (client or server), or UpdateUserReadOnlyData. Permissions for user data are Private by default, meaning that the data can only be read by the server or the player associated with the data. When set to Public, any player is able to read the data.

Note that in the case of user data, only the player associated with the data (in the case of UpdateUserData) or a server call can write to that data. Players cannot write into each others' User Data directly.

Group Data

Finally, PlayFab also has group data, which can be written to by any user in the associated group. A good example of this would be for shared data across a clan, where you want to have data which can be updated by any member of the clan. To use this in your game, you would first create a group using the CreateSharedGroup API call. One you have a group, you can add more users to it using AddSharedGroupMembers, and remove them using RemoveSharedGroupMembers. Once it has been set up, any member of the group can write key value pairs to the group using UpdateSharedGroupData, and read using GetSharedGroupData.

It's also worth noting that the Permission described above, for user data, applies to group data as well. You can make shared group data available to all users, whether they are in the group or not, available for read by setting the Permission to Public, though write operations will still only be accepted by group members.

Also, it's important to note that you can have Shared Group Data with no users added to it at all using the server-side versions of the API calls:

https://api.playfab.com/Documentation/Server/method/CreateSharedGroup

https://api.playfab.com/Documentation/Server/method/UpdateSharedGroupData

etc.

This allows you to create a data space which can be used for any server-side call, including Cloud Script, but which cannot be modified by clients. This is particularly useful for cases where you have data which needs to be kept safe from potentially hacked clients. Our asynchronous game sample is an example of using Shared Group Data this way.

All in One

Finally, developers can retrieve all of a user's account information, user data, read-only user data, and inventory in a single call on the client, using the GetUserCombinedInfo API call. This functions the same way as each of the individual calls, allowing for clients to query data for the local user or another user, with private and public data being managed appropriately.

More information on each of these can be found in the PlayFab documentation pages. If you have any questions on usage, please post them to the PlayFab forums or (if your questions require confidentiality due to IP or competitive concerns), email them to us at devrel@playfab.com.


2 Comments
dragongamestudio said on Wed, 01 April 2015 at 1:51 AM

hello,

in this API https://api.playfab.com/Documentation/Client/method/UpdateUserData
there is some parameter called "Permission" that can be public or private, what if i set it to public?

can some other account read it,

because i need to put some data like invitation or challenge to other account without add that account permission,

for example player A want to invite player B
player A will update some B's data to put some note in B
so, when player B login back, player B will read his own data and will know that player A has invite him,

thank you


Brendan Vanous said on Wed, 01 April 2015 at 2:46 PM

Thanks - I've updated the post to provide some additional information which should help to clarify this, but the key items are:

Public data may be read by any client (player) running your game. Only the "owner" of the data (the player with whom it is associated) or a server call can write to that data.

We created a sample showing management of a turn-based asynchronous game, including matchmaking - here's a link to the post with all the info on this. Adding challenges would be simple - just use Cloud Script to write to the UserReadOnlyData (or UserInternalData) for the player being challenged. Use the PlayFabId of the player issuing the challenge as the Key (so that you don't have collision issues), with the Value being whatever information you need for the game (game mode/type, opening move, etc.). When the player being challenged accepts or rejects the challenge, just remove that Key (set it to null) and you're good to go.

Brendan

1 comment
10 |1200

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

Dale Strickler avatar image Dale Strickler commented ·

I was wondering about latency with the User Data approach. If I set a public data key in Player A's User Data then read it from Player B's client game app, how soon can I expect that key to show up? Clearly, I understand I should not set up a rapid pole loop and I don't keed one. I just wonder, can I trust the data, will be in milliseconds, seconds, minutes, hours? Assuming free teir.

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.