Forum Discussion
DaffyTheBunny
1 year agoStart Member
Friend Leaderboards - Request "after rank"
Hi, I am currently implementing leaderboards (in a Unity project). When displaying all data, I can use the "GetEntriesAfterRank" function to allow the user to 'page up' and 'page down' through the ...
- 1 year ago
I managed to solve the problem. I will share my solution here in case it helps anyone else.
When dealing with the Friends Leaderboard, I download the entire leaderboard and then selectively show whatever I want. To download the entire leaderboard:
Leaderboards.GetEntries( szLeaderboardName, 100, LeaderboardFilterType.Friends, LeaderboardStartAt.Top ).OnComplete( OnFriendLeaderboardDataReceived );100 is the maximum entries you can request at a time so, we must handle the possibility that the user has more than 100 friends (lucky):
void OnFriendLeaderboardDataReceived( Message<LeaderboardEntryList> msg ) { if( !msg.IsError ) { LeaderboardEntryList entries = msg.Data; // Store the entries here (code removed for brevity) // We need to check if there is more data... if( m_NumItemsDownloaded < (int)entries.TotalCount ) { // Request more data Leaderboards.GetNextEntries(entries).OnComplete( OnFriendLeaderboardDataReceived ); } else { // All data downloaded } } else { Error error = msg.GetError(); } }The nice thing is - you can test the code by limiting the initial call to GetEntries to just 1.
Hope that helps someone.
DaffyTheBunny
1 year agoStart Member
I managed to solve the problem. I will share my solution here in case it helps anyone else.
When dealing with the Friends Leaderboard, I download the entire leaderboard and then selectively show whatever I want. To download the entire leaderboard:
Leaderboards.GetEntries( szLeaderboardName, 100, LeaderboardFilterType.Friends, LeaderboardStartAt.Top ).OnComplete( OnFriendLeaderboardDataReceived );100 is the maximum entries you can request at a time so, we must handle the possibility that the user has more than 100 friends (lucky):
void OnFriendLeaderboardDataReceived( Message<LeaderboardEntryList> msg )
{
if( !msg.IsError )
{
LeaderboardEntryList entries = msg.Data;
// Store the entries here (code removed for brevity)
// We need to check if there is more data...
if( m_NumItemsDownloaded < (int)entries.TotalCount )
{
// Request more data
Leaderboards.GetNextEntries(entries).OnComplete( OnFriendLeaderboardDataReceived );
}
else
{
// All data downloaded
}
}
else
{
Error error = msg.GetError();
}
}The nice thing is - you can test the code by limiting the initial call to GetEntries to just 1.
Hope that helps someone.
Quick Links
- Horizon Developer Support
- Quest User Forums
- Troubleshooting Forum for problems with a game or app
- Quest Support for problems with your device
Other Meta Support
Related Content
- 11 months ago
- 1 month ago
- 2 months ago