I am writing a custom leaderboard and I just want to know given the player ID, where he/she is on the leaderboard.
I have found this thread: Rank of Local authenticated player in All Time best in game center leaderboard
But I am having trouble implementing it. Here is what I have:
-(void) retrieveScoresForPlayers:(NSArray*)players
category:(NSString*)category
range:(NSRange)range
playerScope:(GKLeaderboardPlayerScope)playerScope
timeScope:(GKLeaderboardTimeScope)timeScope
{
if (isGameCenterAvailable == NO)
return;
GKLeaderboard* leaderboard = nil;
if ([players count] > 0)
{
//leaderboard = [[[GKLeaderboard alloc] initWithPlayerIDs:players] autorelease];
leaderboard = [[[GKLeaderboard alloc] initWithPlayerIDs:[NSArray arrayWithObject:[GKLocalPlayer localPlayer]]] autorelease];
}
else
{
leaderboard = [[[GKLeaderboard alloc] init] autorelease];
leaderboard.playerScope = playerScope;
}
if (leaderboard != nil)
{
leaderboard.timeScope = timeScope;
leaderboard.category = category;
leaderboard.range = range;
[leaderboard loadScoresWithCompletionHandler:^(NSArray* scores, NSError* error)
{
[self setLastError:error];
//[delegate onScoresReceived:scores];
if (_gkhDelegate != NULL) {
_gkhDelegate->onScoresReceived([self convertNSArrayOfGKScoresToCppVector:scores]);
}
}];
}
}
Whenever I print the rank though, it is always 1 regardless of the actual number. I suspect it's returning the rank in the query. How do I return the abolute position in the leaderboard?