Hi everyone.
I am trying to use Steam leaderboards in mostly blueprint game (got some C++ too, but I would like to keep it simple). I have Steam Works set up, stats and achievements are working good (after creating BP node for stats). But have problem with leaderboards, I have no idea whats wrong.
When using “Write Leaderboards Integer” (like on screenshot):
there was an error with doubled leaderboard name (name passed to BP node):
LogOnline:Warning: STEAM: Steamworks SDK warning: [S_API WARN] GetStat() failed, stat singleplayerScore_singleplayerScore does not exist - needs to be first configured on the Steamworks site
LogOnline:Warning: STEAM: Failure to write key value pair when uploading to Steam singleplayerScore_singleplayerScore=57364
I don’t understand why Leaderboards are mixed with Steam Stats, but found the place in code where doubled names are created:
In LeaderboardBlueprintLibrary.cpp @ 97 Write object is created with:
bool ULeaderboardBlueprintLibrary::WriteLeaderboardInteger(APlayerController* PlayerController, FName StatName, int32 StatValue)
{
FOnlineLeaderboardWrite WriteObject;
WriteObject.LeaderboardNames.Add(StatName);
...
WriteObject.SetIntStat(StatName, StatValue);
return WriteLeaderboardObject(PlayerController, WriteObject);
}
Then in OnlineLeaderboardInterfaceSteam.cpp @ 1351 Stat name is passed as both arguments in:
FName LeaderboardStatName = GetLeaderboardStatName(WriteObject.LeaderboardNames[LeaderboardIdx], It.Key());
and in OnlineLeaderboardInterfaceSteam.cpp @ 16 doubled name is created.
inline FName GetLeaderboardStatName(const FName& LeaderboardName, const FName& StatName)
{
return TCHAR_TO_ANSI((*FString::Printf(TEXT("%s_%s"), *LeaderboardName.ToString(), *StatName.ToString())));
}
I changed GetLeaderboardStatName function to give one name if two arguments are the same with hope to see some leaderboard entries on SteamWorks page, but that didn’t help. Error with non existing leaderboard disappeared, but no entries where created. I admit once again: don’t understand this Leaderboard and Stats mix up, and I am not sure if that change was good
In logs I got:
LogOnline:Warning: STEAM: Failure to write key value pair when uploading to Steam singleplayerScore=19996
LogOnline:Warning: Async task ‘FOnlineAsyncTaskSteamUpdateStats bWasSuccessful: 0 User: Slimak [0x110000104A5A63D]’ completed in 0.801725 seconds with 0
LogOnline:Warning: Async task ‘FOnlineAsyncTaskSteamUpdateLeaderboard bWasSuccessful: 0 Leaderboard: singleplayerScore Score: 0’ completed in 0.801878 seconds with 0
and for now I have no idea how to make it work. When testing this I got leaderboards reading set up in other BP so logs could be mixed with reading/writing.
Does anybody have an idea what’s wrong, and could share it?