Yes, in another post I’m trying to use the StatisticsManager::GetLeaderboard call but I haven’t worked out the third parameter yet.
bool FOnlineLeaderboardsLive::ReadLeaderboardsAroundUser(TSharedRef<const FUniqueNetId> Player, uint32 Range, FOnlineLeaderboardReadRef& ReadObject)
{
if (!LiveSubsystem)
return false;
//Currently Xbox One only supports single column leaderboards. If more than one column is requested, fail the request for now.
if (ReadObject->ColumnMetadata.Num() > 1)
{
UE_LOG_ONLINE(Warning, TEXT("Failing Leaderboards request for multiple columns. Xbox One currently only supports single-column leaderboards."));
TriggerOnLeaderboardReadCompleteDelegates(false);
return false;
}
const FOnlineIdentityLivePtr Identity = LiveSubsystem->GetIdentityLive();
if (!Identity.IsValid())
return false;
const FUniqueNetIdLive UserLive(Player.Get());
Windows::Xbox::System::User^ XBoxUser = Identity->GetUserForUniqueNetId(UserLive);
if (!XBoxUser)
return false;
//Microsoft::Xbox::Services::XboxLiveContext^ LiveContext = LiveSubsystem->GetLiveContext(XBoxUser);
XboxLiveContext^ LiveContext = LiveSubsystem->GetLiveContext(XBoxUser);
if (LiveContext == nullptr)
return false;
//Microsoft::Xbox::Services::Statistics::Manager::StatisticManager^ mgr = Microsoft::Xbox::Services::Statistics::Manager::StatisticManager::SingletonInstance;
StatisticManager^ mgr = StatisticManager::SingletonInstance;
if (mgr == nullptr)
return false;
try
{
Platform::String^ StatName;
if (ReadObject->ColumnMetadata.Num() > 0)
{
StatName = ref new Platform::String(*ReadObject->ColumnMetadata[0].ColumnName.GetPlainNameString());
}
if (StatName->Length() == 0)
{
UE_LOG_ONLINE(Warning, TEXT("Failing Leaderboards request. No statistic requested for friends leaderboard."));
ReadObject->ReadState = EOnlineAsyncTaskState::Failed;
TriggerOnLeaderboardReadCompleteDelegates(false);
return false;
}
ReadObject->ReadState = EOnlineAsyncTaskState::InProgress;
// Clear out any existing data
ReadObject->Rows.Empty();
mgr->GetLeaderboard(LiveContext->User, StatName, nullptr);
}
catch (Platform::Exception^ ex)
{
UE_LOG_ONLINE(Warning, TEXT("GetLeaderboard failed. Exception: %s."), ex->ToString()->Data());
ReadObject->ReadState = EOnlineAsyncTaskState::Failed;
TriggerOnLeaderboardReadCompleteDelegates(false);
return false;
}
return true;
}
I’m using ReadLeaderboardsAroundUser since it previously wasn’t implemented for my tests. I can replace the ReadLeaderboards function if I can get it working properly.
Do you know about the LeaderboardQuery parameter?