Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

When using LoadScores with SetUserFilter the Scores list returns empty #2876

Closed
giacomelli opened this issue Apr 25, 2020 · 3 comments
Closed

Comments

@giacomelli
Copy link

giacomelli commented Apr 25, 2020

When using LoadScores with SetUserFilter the scores list returns empty:

var leaderboard = Social.CreateLeaderboard();
leaderboard.id = "leaderboard id";
leaderboard.SetUserFilter(new string[] { Social.localUser.id });
leaderboard.LoadScores(success =>
{
    if (success)
        Debug.Log($"Scores: {leaderboard.scores.Length}");
});

The Debug.Log line will always write"Scores: 0".

@giacomelli
Copy link
Author

The code block that is causing the error is this one:

if (fid.Equals(score.userID))
{
    return mScoreList.Count;
}

If the scores' userID is equal to any on the list the AddScore method is returning before adding the score to the list.

The code below fixes the problem:

internal int AddScore(PlayGamesScore score)
{
    if (mFilteredUserIds == null || mFilteredUserIds.Length == 0)
    {
        mScoreList.Add(score);
    }
    else
    {
        foreach (string fid in mFilteredUserIds)
        {
            if (fid.Equals(score.userID))
            {
                mScoreList.Add(score);
                break;
            }
        }
    }

    return mScoreList.Count;
}

@ozdemir08
Copy link
Contributor

Can you create a pull request with this change please?

@atifbuttgss
Copy link

I think this Function call returns only last 20 Leaderboard enteries instead of returning all enteries.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants