question

mail-1 avatar image
mail-1 asked

Possible to save something straight to another player's data?

Hi,

I'm coming from a Parse background, so certain things in the documentation are still not that clear to me.

I would like to switch to PlayFab now, but I'm not sure about whether it allows certain data operations.

Say I have some amount of players. Each player can 'choose' another one and duel with their character (this is not really true multiplayer - no need for player2 to affect player1 in any way).

So

1. Can an authenticated player1 change a player2's data, as in add a key-value pair to them, "player-id-1=dueledYouAnWon" etc. so that player2 can later see who dueled them and what was the result?

2. Can a player1 retrieve a list of all other players who meet certain criteria? (e.g. "userExperience>1000") so I can show a list of available opponents to them?

If this is possible, coud you point me to what to look for in the documentation?

Thanks

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

The way to change data cross-player would be via Cloud Script, as it has full access to the Server API. It's important to be careful in the design of this though, as if both players were to issue write calls at the same time (rare, but possible), only the last write would succeed. If you're tracking on whose turn it is in the data, and only letting that player push an update though, that should be fine.

For finding players to challenge based upon them being near the requesting player in terms of experience, we'd recommend storing the experience as a statistic. All stats in the service are leaderboards, so you could then just use GetLeaderboardAroundPlayer to get a list of other players with similar scores.

10 |1200

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

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.