question

grygus87 avatar image
grygus87 asked

,How to sum statistics of all players for specific character?

,

Hi guys, I need to make leaderboard of "game characters" in this way that each character overall score is sum of best scores of all players played with it. How could I achieve this? The only way that is coming to my mind is to use cloud script that triggers on statistic update than score value is added to TitleData. Is there any onther way?

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

Please see this post for more information on this topic: https://community.playfab.com/questions/956/211248347-Writing-Title-Data-in-Cloud-Script.html.

Title Data should never be updated as a result of a player action. The Title Data update call is only in the Server API so that it can be used as part of changing Title Data in a non-segment scheduled task, in support of changing title configuration values for an event. Please understand that for a data value to be readable by all players, it must be sharded and cached. Consequently, there is a delay from when the value is updated to when all caches have the updated value - which in turn means that you would have consistency issues in attempting to do this (as well as hitting update frequency limits).

A generic data store that can be updated by all players, and be read by all players, with consistency of the data, would be extremely expensive to operate - systems that allow for all-player read/write are, generally speaking, custom built with the requirements of the feature in mind. To accomplish what you describe, I'd recommend using an external data store (Redis would be my pick).

2 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.

grygus87 avatar image grygus87 commented ·

Thanks Brendan for the answer it is very clear. But what if updating those leaderboards data would be sheldued once per day, i think in my case it would be enough, In other words players would be updating statistics for characters like usual, and cloud script would be sheldued to sum statistics and save to title data once per day. Would it be ok?

0 Likes 0 ·
brendan avatar image brendan grygus87 commented ·

No, I'm sorry, but Title Data cannot be used that way. It is designed to be an infrequently-updated store of global data for all players. You should only ever update it from the Game Manager, an admin tool that you use to make updates as needed, or a non-segment scheduled task.

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.