Hello,
I’m currently setting up stats and achievements to work via EOSPlus(EOS+Steam) and I made the QueryStats and UpdateStats functions, but I’m not getting the callback of the delegates.
Both Steam and Epic overlays work fine.
Client policy has a full configuration.
But I keep getting Updating Stats… and Querying Stats… and no other messages at all.
What could be a problem?
void UEOSGameInstance::QueryUserStats(TArray<FString> StatName)
{
if (OnlineSubsystem)
{
if (IOnlineStatsPtr StatsPtr = OnlineSubsystem->GetStatsInterface())
{
if (IOnlineIdentityPtr Identity = OnlineSubsystem->GetIdentityInterface())
{
FUniqueNetIdRef UserNetId = Identity->GetUniquePlayerId(0).ToSharedRef();
TArray<TSharedRef<const FUniqueNetId>> TargetUsers;
TargetUsers.Add(UserNetId);
StatsPtr->QueryStats(UserNetId, TargetUsers, StatName, FOnlineStatsQueryUsersStatsComplete::CreateUObject(this, &UEOSGameInstance::OnQueryUsersStatsComplete));
UE_LOG(LogTemp, Display, TEXT("Querying Stats..."));
return;
}
}
}
UE_LOG(LogTemp, Error, TEXT("Failed to Query Stats"));
}
void UEOSGameInstance::UpdateUserStats(FString StatName, int32 Value)
{
if (OnlineSubsystem)
{
if (IOnlineStatsPtr StatsPtr = OnlineSubsystem->GetStatsInterface())
{
if (IOnlineIdentityPtr Identity = OnlineSubsystem->GetIdentityInterface())
{
FOnlineStatsUserUpdatedStats StatVar = FOnlineStatsUserUpdatedStats(Identity->GetUniquePlayerId(0).ToSharedRef());
StatVar.Stats.Add(StatName, FOnlineStatUpdate(Value, FOnlineStatUpdate::EOnlineStatModificationType::Set));
FUniqueNetIdRef UserNetId = Identity->GetUniquePlayerId(0).ToSharedRef();
TArray<FOnlineStatsUserUpdatedStats> StatArray;
StatArray.Add(StatVar);
StatsPtr->UpdateStats(UserNetId, StatArray, FOnlineStatsUpdateStatsComplete::CreateUObject(this, &UEOSGameInstance::OnUpdateUserStatsComplete));
UE_LOG(LogTemp, Display, TEXT("Updating Stats..."));
}
}
}
}
void UEOSGameInstance::OnQueryUsersStatsComplete(const FOnlineError& ResultState, const TArray<TSharedRef<const FOnlineStatsUserStats>>& QueriedStats)
{
UE_LOG(LogTemp, Display, TEXT("OnStatsQueryUserStatsComplete: %s"), *ResultState.ToLogString());
}
void UEOSGameInstance::OnUpdateUserStatsComplete(const FOnlineError& ResultState)
{
UE_LOG(LogTemp, Display, TEXT("OnUpdateUserStatsComplete: %s"), *ResultState.ToLogString());
}
