question

scholarlyorc7 avatar image
scholarlyorc7 asked

GetLeaderboard and GetFriendLeaderboard always return empty

Hello,

Our game has several test users with statistics, that build up some leaderboards. I've been trying to retrieve those leaderboards using GetFriendLeaderboard in Unity. When I constantly recieved an empty array, I thought the problem might have something to do with the friends system, so I tried using GetLeaderboard. For some reason, this call would also return an empty array.

Wierdly enough, when I try to call GetLeaderboard through the "Try it" option in the relevant documentation page, everything works just fine. It seems like something in the call I make is not right, but I can't figure what.

These are the request and the call I make:

       GetLeaderboardRequest levelRequest = new GetLeaderboardRequest()
        {
            StatisticName = SaveLoadController.current.saveHighestLevel,
            StartPosition = 0,
            MaxResultsCount = 0           
        };


        PlayFabClientAPI.GetLeaderboard(levelRequest, 
            (result) => //On success
            {
                Debug.Log("LEVEL returned with: " + result.Leaderboard.Count);
                highestLevels = result.Leaderboard;
                dataRetrieved++;
                if (dataRetrieved == expectedDataOfFriends)
                {
                    Debug.Log("got enough info, adding friends");
                    AddFriendInfo(friendsInfo, highestLevels, highScores);
                }
            },
            (result) => //On fail
            {
                Debug.LogError("User LEVEL stats couldn't be retrieved");
                PlayFabErrorHandler.HandlePlayFabError(result);
            });

Thanks in advance,

Scholarly Orc team.

Leaderboards and Statistics
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.

scholarlyorc7 avatar image scholarlyorc7 commented ·

Hi Branden, thanks for the reply.

saveHighestLevel is a string equals to "highestLevel". This is one of our statistics / leaderboards names.

The title ID is A448.

Thanks again,

Scholarly Orc team.

1 Like 1 ·
brendan avatar image brendan commented ·

What does the saveHighestLevel string resolve to, and what Title ID is this for?

0 Likes 0 ·

1 Answer

·
brendan avatar image
brendan answered

I don't know I missed seeing this the first time, but you've specifying a MaxResultsCount of 0 in the call - in other words, you're telling the service to return no entries. Could you try changing that (or just removing it - the default is 10)?

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.

scholarlyorc7 avatar image scholarlyorc7 commented ·

Well that's embarrassing! I have no idea how this line got there. Now all is working fine.

Anyway, I think I might have found a related bug: when I remove the MaxResultsCount altogather, the call returns an empty array, just like before. It is as if the default for this property is 0. When I explicitly define this property (say = 10), it returns normally.

Thanks again for your help!

0 Likes 0 ·
brendan avatar image brendan scholarlyorc7 commented ·

That's odd - I'm seeing the default number of results in my own testing. Can you provide your repro steps, and do you mind if I create a player in your title (A448)?

0 Likes 0 ·
scholarlyorc7 avatar image scholarlyorc7 brendan commented ·

I'd happily provide those, though I'm not sure how in this occasion. Could you describe how would you like to get those?

And please, go ahead and create a player! Anything to promote debugging! :)

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.