question

wendsaaaa avatar image
wendsaaaa asked

how can i Update Player statistics using my code in c#? is there any clear tutorial for this? icant understand the documentation.

CloudScript
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

It could be better if you tell us which part you do not understand so that we can offer you some explanations.

According to our documentation Using Resettable Statistics and Leaderboards, to update statistics, you can use UpdatePlayerStatistics API calls

The following is an example.

// first you need to login, I will skip this part
// Then, Define the StatisticUpdate list
List<StatisticUpdate> myUpdate = new List<StatisticUpdate> 
{ 
    new StatisticUpdate 
    {
        StatisticName="your statistic name", Value = 123
    }
};

PlayFabClientAPI.UpdatePlayerStatistics(
    new UpdatePlayerStatisticsRequest
    {
        // you can see in the API document the UpdatePlayerStatisticsRequest needs List<StatisticUpdate> variable
        Statistics = myUpdate
    },
    onSuccessCallback => { },
    onFailureCallback => { }
);

Please see details about UpdatePlayerStatisticsRequest here and StatisticUpdate here.

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.