question

moayadrahhal avatar image
moayadrahhal asked

How can I listen on some values

Hello, In my game I have two teams playing with each other and there is a score for each one, so if one of the players from team 1 wins then the value of the team will be increased, I need to update the value on other players if they currently opened same windows that show the scores.

Shared Group Data
3 comments
10 |1200

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

Gosen Gao avatar image Gosen Gao commented ·

May I know where do you store the value of the team? If you store it in the Player Data of each player on the team, then when you need to display the score, you can get it from any player's Player Data. If you mean you want the scores refresh when it updates, you need to poll it.

0 Likes 0 ·
moayadrahhal avatar image moayadrahhal Gosen Gao commented ·

Well, let me explain what I want.

I have two teams.

Team1 => player1, player2, and player3 => scoreTeam1

Team3 => player4, player5, and player6 => scoreTeam2

Here I have two scores(scoreTaem1, and scoreTeam2), one for Team1, and one for Team2, so (player1, 2, and 3) share the same value, and also for Team2 (player4, 5, and 6).

And there is a window in the game that shows the scores for the teams.

I'm assuming that, TitleData will be like this

{ "Team1_ID": "11", "Team2_ID": "12", "score_team1": 0, "score_team2": 0 }

My questions:

Is the best place to save the data is TitleData because it shares with all players?

If player 1 from team 1 adds a score, how will players 2 and 3 know the new value?

Do I need to update the value when sending player points to store again in TitleData or use Statistics to store the data for each player and get the total score for the team thru the leaderboard? and is the maximum leaderboard 100 users to get, if yes what if I have more than 100 players?

Is it right if I would store it in TitleData when sending data from any player, I can add the score by cloud script and there should get the score then add the new score or what?

Thanks

0 Likes 0 ·
drallcom3 avatar image drallcom3 commented ·

Playfab doesn't have such a functionality (e.g. Websockets).

0 Likes 0 ·

1 Answer

·
Gosen Gao avatar image
Gosen Gao answered

- Is the best place to save the data is TitleData because it shares with all players?

Title Data is not suit for your scenario, as "Title Data values are copied and distributed to potentially hundreds of machines in the PlayFab server cluster. As part of this process, Title Data is cached, and changes may take up to fifteen minutes to refresh in those caches. Title Data is best suited for Global Constant/Static Data and is not suitable or reliable as Global Variables."

The Statistics is not suitable as well, if lots of players are playing, you may not be able to get the current players' score. I would suggest you store it in a Shared Group Data created for each game. Refer to Using Shared Group Data.

- If player 1 from team 1 adds a score, how will players 2 and 3 know the new value?

Since PlayFab core service is based on RESTful API, the other players need to poll it to know if the value is updated.

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.