Search code examples
c#xamluwpleaderboardxbox-live

UWP Xbox Live Leaderboards


I am trying to incorporate leaderboards into my UWP game. I am using C# and XAML to create my game. I have created a high score leaderboard and have pushed it with the test button in the dash board.

I have pushed a record to the leaderboard by calling:

_stats.SetStatisticIntegerData(XboxUser, "score", XP);
_stats.RequestFlushToService(XboxUser, true);

I receive a successful response from the server.

When I try to retrieve the leaderboard from the server by the following:

_stats.GetLeaderboard(XboxUser, "score", new LeaderboardQuery());

I get back a successful response.

The problem is I do not receive any rows with my response. I get back one column with the displayName of High Score, but no rows.

Does anyone know what I am doing incorrectly?

UPDATE A bit more information:

I have created a leaderboard with the ID of score.

when I call the following:

var val = _stats.GetStatistic(XboxUser, "score");

It throws the following exception:

The parameter is incorrect.

Stat not found in document

When I store the data into the leaderboard I get the following:

Static Event:

ErrorCode: 0

ErrorMessage: ""

EventArgs: null

EventType: StatisticUpdateComplete

User: my User


Solution

  • I have the answer! Before calling add static or getting the Leaderboard you have to wait until the StatisticEventType.LocalUserAdded Event completes.