question

Paul Bell avatar image
Paul Bell asked

Noob here leaderboard help ,Noob here help with leaderboards.

Hi,


thank you for taking the time to read this;


I have an issue getting player data to populate my leaderboard.


I have 2 stats/ leaderboards.

Stat/ leaderboard 1 - the playerHighScore

Stat/leaderboard 2 - the level the high score was achieved on


I would like my high score table to look something like


Rank. High Score. Level. Player Name

01. 10000. 05. Player1

02. 6000. 12. Player2

Etc


I can successfully populate from one leaderboard using get leaderboard request, but I cannot figure out how to get the second player stat to populate the leaderboard.

I tired a separate leaderboard request and cycling through checking the playerfab ids but after the game grows past 100 users this will not work.


anyway to grab that data?


thank you in advance

,

Ok, thank you for taking the time to read this I have come up against a brick wall.

I have a leaderboard for the players top score , on my leaderboard I would also like to display the level with which the top score was achieved on.

ie. rank level score display name

01 04 1000 player one

02 06. 780. Player two

Each individual player has the level saved as an int on the player stats (which can be another leaderboard).


leaderboard /stat 1 contains the top score

Leaderboard / stat 2 contains the level.

I can return and build a leaderboard for the top score, but i can’t figure out how to retrieve the leaderboard stat 2 for the same player at the same time.

Hopefully a simple fix, thank you in advance.

Player DataLeaderboards 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.

Seth Du avatar image
Seth Du answered

You may define ProfileConstraints to get additional information when calling GetLeaderboard API.

{
    "StatisticName": "High Score",
    "StartPosition": 0,
    "MaxResultsCount": 20,
    "ProfileConstraints":
    {
        "ShowStatistics" : true
    }
}

The highest level will be displayed in the form of Statistics, however, it doesn’t support displaying the rank of 2nd leaderboard. If it is required, you may call GetLeaderboard API twice then combine 2 results and group by PlayFab ID.

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

Paul Bell avatar image Paul Bell commented ·

that’s exactly what I have been trying to do, I don’t need the rank of the 2nd stat.


Maybe me missing something stupid but I cannot still get it to work.

I even thought about saving the levels number as the display name and using username for the players name but I can’t seem to even get that to work.

0 Likes 0 ·
Seth Du avatar image Seth Du ♦ Paul Bell commented ·

May I ask what is the issue you have at the moment? Do you have any error callbacks from PlayFab API calls?

If you have any trouble in integrating PlayFab SDK, you may try to use Postman to get used to the usage of PlayFab API -- Postman (REST) SDK - PlayFab | Microsoft Docs.

0 Likes 0 ·
Paul Bell avatar image
Paul Bell answered

sorry I didn’t explain myself very well,my issue seems to be with the code I need to write for this, in c# with unity.

More specifically I can set the stats available by code (as you replied with) or on the playfab settings, it I cannot recall them. Probably me been inexperienced.

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.

Seth Du avatar image Seth Du ♦ commented ·

Is it Unity or C# project? PlayFab provides separate SDKs for these 2 platforms.

0 Likes 0 ·
Paul Bell avatar image
Paul Bell answered

Sorry it’s a unity project, I have managed a work around but still very curious if this is possible

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.

Seth Du avatar image Seth Du ♦ commented ·

It will be like this:

PlayFabClientAPI.GetLeaderboard(
    new GetLeaderboardRequest {
        StartPosition = 0,
        MaxResultsCount = 20,
        StatisticName = "Points",
        ProfileConstraints = new PlayerProfileViewConstraints {
            ShowStatistics = true
        }
    },
    result => {},
    error => {}
    );
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.