question

manolhsplaths46 avatar image
manolhsplaths46 asked

How to increase score when the currentScore is higher?

Speak to me with codes than articles. Article reading seems to me chinese xD no offense xD

What i want to do is increase this score only when the current score is higher than the previous one,

With this line i am using the gamemanager.instance.score to put the value from my other class script and add it to the database. i am using playfab.

var stat = new StatisticUpdate { StatisticName = "Coins", Value = GameManager.Instance.score};
         request.Statistics.Add(stat);

if i knew my highscore i would do an if statement gamemanager.instance.score with highscore and then i would add the

var stat = new StatisticUpdate { StatisticName = "Coins", Value = GameManager.Instance.score};
         request.Statistics.Add(stat);
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

·
Andy avatar image
Andy answered

Unfortunately, the answer to your question doesn't require code. :)

You want to use the "Max" aggregation method. It will ensure that each update of the stat only matters if the provided value is higher.

You can set this via the Leaderboards tab or through the admin api: https://api.playfab.com/documentation/Admin/datatype/PlayFab.Admin.Models/PlayFab.Admin.Models.StatisticAggregationMethod

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

manolhsplaths46 avatar image manolhsplaths46 commented ·

it needs code, i don't know how to reference in unity the aggrevation method pff

0 Likes 0 ·
brendan avatar image brendan manolhsplaths46 commented ·

You can set the aggregation method in the Game Manager, in the settings for the leaderboard associated with the statistic, or you can set it via https://api.playfab.com/documentation/Admin/method/UpdatePlayerStatisticDefinition

0 Likes 0 ·
manolhsplaths46 avatar image manolhsplaths46 brendan commented ·

ya but how ? i need a code lolz this does not work in unity... pff

"StatisticName": "headshots",
0 Likes 0 ·
Show more comments

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.