question

sepehr99gh avatar image
sepehr99gh asked

Is there an easy route to having leaderboard ranks start from 1 (Not 0)

Hi all,

I've got the following script (section specific) to display a players name, rank and score throughout numerous, separate, leaderboards

     void OnGetLeaderboard(GetLeaderboardResult result)
     {
         leaderboardMasterPanel.SetActive(true);
        // Debug.Log(result.Leaderboard[0].StatValue);
         foreach(PlayerLeaderboardEntry player in result.Leaderboard)
         {
             GameObject tempListing = Instantiate(listingPrefab, listingContainer);
             LeaderboardListing LL = tempListing.GetComponent<LeaderboardListing>();
             LL.playerRank.text = player.Position.ToString();
             LL.playerNameText.text = player.DisplayName;
             LL.playerScoreText.text = player.StatValue.ToString();
             Debug.Log(player.DisplayName + ": " + player.StatValue);
         }
            
     }

This works perfectly, however Playfab standard starts the leaderboard player position(Rank) count from 0. Is there a simple way to have this start from 1?

Thanks!

Leaderboards 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

·
Xiao Zha avatar image
Xiao Zha answered

PlayFab doesn’t provide such feature to having leaderboard ranks start from 1. You can modify your code like this: LL.playerRank.text = (player.Position+1).ToString();.

1 comment
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

sepehr99gh avatar image sepehr99gh commented ·

Well cheers

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.