question

Deekshith avatar image
Deekshith asked

Sum of a particular statistic value

My game will have a statistic in each player.

Consider statistic "kills". So when a player kills a enemy the statistic value is incremented and so on.

So I would need the sum of these values i.e. total enemies killed by all the players.

Is there any way to get sum of these statistic values?

Player DataLeaderboards and Statistics
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

·
Seth Du avatar image
Seth Du answered

Though the best solution for this scenario should be implementing external database server or Redis to handle multiple write operations with cache, there are feasible work around solutions via PlayFab.

Since the update of statistics will generate PlayStream Events, you may either use the current built-in events or generate a custom event via WritePlayerEvent every time the statistic is changed. Then use PlayFab Explorer ([Game Manager] -> [Data] -> [Explorer]) to query. You may use Kusto query language to retrieve and sum the whole data. However, PlayFab Explorer service stores 30 days of title data. Note that only 14 days are held in the cache, meaning queries limited to 14 days will be most performant. In the future, these limits will also be configurable through a self-service experience. It also means you need to manually run the query at lease every month to store it somewhere like Title Data.

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.

Deekshith avatar image Deekshith commented ·

Cannot the sum of these statistics be done in the code itself?

0 Likes 0 ·
Seth Du avatar image Seth Du ♦ Deekshith commented ·

Yes, you can, but the process will take long if you have a very large number of players. GetLeaderboard API call can only retrieve 100 entries at a time. You may programmatically calculate the statistics on an external server instead of Cloud Script because it has high possibility to exceed the execution runtime limits. Besides, number of PlayFab API requests made from a Cloud Script function called by the ExecuteCloudScript API has a limit, which is 15 for Essential Tier.

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.