question

Riccardo Iengo avatar image
Riccardo Iengo asked

Create/Update Statistics via Cloud Script Best Practice

Hi,

In order to correctly update a statistic on Playfab what is the best way to go?

Do I have to create the Statistics I want beforehand (via cloud for example with value 0 and fill with value whenever I need it)

OR

can I directly Set and Update a Statistic with a value from my game? Will this second option give me troubles or it's safe?

Thanks for your help!

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

·
Sarah Zhang avatar image
Sarah Zhang answered

>> Do I have to create the Statistics I want beforehand (via cloud for example with value 0 and fill with value whenever I need it)

When you upload a Statistics with a new statistics name, PlayFab would create a new leaderboard for it. So, you needn't to pre-create the Statistics whose value is 0.

>> can I directly Set and Update a Statistic with a value from my game? Will this second option give me troubles or it's safe?

As the above answer said, if the Statistics name is new, PlayFab would create the new leaderboard for these statistics. You need to verify the statistics value on CloudScript to avoid security problems and do the necessary verifications to the statistics name to avoid wasting resources due to typo.

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.