question

Ejandra Mae Dimacali avatar image
Ejandra Mae Dimacali asked

Is there a way to grant a prize based on the range of the player's statistic and not on the leaderboard rank?

I have a leaderboard for the ranked points for the season of the players that resets monthly. I wanted to grant players rewards based on their earned ranked points for the season and not based on their ranking on the leaderboard. Prize Table only considers the rank of the player for the prize.How should I accomplish this with PlayFab?

Player DataapisLeaderboards 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

·
Citrus Yan avatar image
Citrus Yan answered

Prize Table only considers the rank of the players, which is by design, therefore, that’s something we cannot change. However, we can customize the rewards granted to each player who falls into that range by running a Cloud Script Function on each of them. As you can see, the context field passed to the Cloud Script Function contains some valuable information (please note that some data are omitted using ‘…’):

{ 
"playerProfile":{..}, 
"playStreamEvent":{ 
"EventName":"player_ranked_on_leaderboard_version", 
"Rank":1, 
"Value":2, 
"Version":1, 
"VersionChangeBehavior":"ResetValues", 
"LeaderboardSource":{ 
"Statistic":{ 
"StatisticName":"s", 
"StatisticId":1017664233 
} 
}, 
…

}

In your case, you may want to get the Value property, which represents the ranked points, and grant rewards to players based on that. Please feel free to reach to us if you have any questions.

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.

Ejandra Mae Dimacali avatar image Ejandra Mae Dimacali commented ·

Thanks for this but I checked on player_ranked_on_leaderboard_version event and saw that it still does not reward everyone but only the top ones on a leaderboard. I think I will just implement this by checking the leaderboard version returned on GetLeaderboard to determine if the leaderboard has already reset. When leaderboard has reset, that's when I grant the reward to the user.

0 Likes 0 ·
Citrus Yan avatar image Citrus Yan Ejandra Mae Dimacali commented ·

If the leaderboard has reset, the responding statistic will also be erased, you'll need to find a way to cache that in other places.

0 Likes 0 ·
Ejandra Mae Dimacali avatar image Ejandra Mae Dimacali Citrus Yan commented ·

Yes, I have decided to use another statistic which reflects the original ranked points but this statistic should never reset unless the reward has been reaped.

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.