How to use Steam Leaderboards from BP?
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:
Then in OnlineLeaderboardInterfaceSteam.cpp @ 1351 Stat name is passed as both arguments in:
and in OnlineLeaderboardInterfaceSteam.cpp @ 16 doubled name is created.
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? :)
I got some things figured out.
To use Steam leaderboards from BP (with Write Leaderboards Integer) we need to create both Steam Stat and Steam Leaderboard with same name. If name doubling is sill in place names on Steam Works should be doubled with underscore in middle, ie.:
I use my single name tweak so I put same in name in all cases.
I got working reads and writes to leaderboards with that. But there was another problem. Writes to Steam Stats are made additive in the code (new values are added to old ones). That caused strange reads at the begging: two writes with values 5000 and 10000 gave me 15000 when red. I could change BP to update stats with delta values, but we already use absolute values for mobiles...
I made change in Engine\Source\Runtime\Online\OnlineSubsystemSteam\Private\OnlineLeaderboardInterfaceSteam.cpp @ 296
Few lines further there is second case for float stats and made same change there.
as with: "also if we tried to do this for more then one stat neither would work at all"
New writes/reads are blocked if made before previous one finished. All worked fine when stats access was done separately.
btw: I am sorry for abandoning my topic for 2 weeks, had other urgent things to focus on. Thank you, HughieDM for hints.
And about "Using Steam Stats form BP", where can put my code snipets??
answered Jul 31 '15 at 03:31 PM
I've made a thread on a tutorial to fix this issue (and credited the one who seemed to have found it first). Hope it helps many with the same issue.
answered May 14 '16 at 03:51 AM
Just a heads up for anyone who is working with this issue in 4.19 and wants to keep it in Blueprints.
Write Leaderboard Integer -node writes as follows in 4.19: Steam Stat with "name_name" Steam Leaderboard with "name"
I confirmed this by creating an achievement linked to a stat with name_name, and it updated. The Leaderboard was created automatically on first call of the Write Leaderboard Integer -node.
answered Nov 18 '18 at 10:29 PM
Follow this question
Once you sign in you will be able to subscribe for any updates here