C++ Read Steam Leaderboard - How to?

Hi folks,

I have the Steam Overlay running and I am able to write and read Steam Leaderboards stats. Tested with my project uploaded to Steam.
So I guess everything is set up correctly.

What I have done so far:

  • set defaultengine.ini settings
  • plugin activated
  • user & leaderboard blueprints and steam overlay tested
  • changed line OnlineLeaderboardInterfaceSteam.cpp (OldValue + Value part)
  • recompliled project after added to build.cs
PrivateDependencyModuleNames.Add("OnlineSubsystem");
  PublicDependencyModuleNames.AddRange(new string[] {
    "OnlineSubsystem",
    "OnlineSubsystemUtils",
    "Steamworks"
    });

  DynamicallyLoadedModuleNames.Add("OnlineSubsystemSteam");

I created a c++ class in Editor as there is no way to read the leaderboard properly with blueprints. Now am trying to get the “Step by Step” guide (Step by Step: Leaderboards (Steamworks Documentation)) from Steam to work, which is making me insane.
I have read through every post I could find besides Epic, Rama and Steam articles but I can’t get it right for a few days now.

I don’t know what to do exactly as I haven’t done any coding so far. My goal is to create blueprints out of the class but I dont even know where to put which code in. Everyone just states “put xy in project” but I don’t know where.

here are my questions: (tl;dr starts here)

I’d be happy to see your c++ files but I guess I can make it own my own if you point me to the right direction.

  1. where do I put the code from the “step by step” guide? tried it with empty classes and actors
  2. where does stuff like SteamAPI_Init() go into?

hey at least include “ThirdParty/Steamworks/Steamv132/sdk/public/steam/steam_api.h” doesn’t bring up any failures when compiling ^^

thanks in advance for any help

SteamAPI_Init and other portions of that code are found in the online subsystem implementation for Steam. Where IOnlineSubsystem is an abstraction to a number of 3rd party services, like Steam, Oculus, Google, and Apple.

To create a ReadLeaderboard node specifically for Steam, you can inherit from UOnlineBlueprintCallProxyBase and use SteamLeaderboard_t. However, if you can’t code, you won’t get very far down that road.

Thanks for your answer!

/edited the post as there is an example available

credits to ryangadz who is providing all the necessary files

Using Steam APIs these C++ classes will allow you to read and write to the steam leaderboards in Unreal Engine 4 with Blueprint nodes

where do I put the code from the “step by step” guide? tried it with empty classes and actors
A lot of the Steamworks Leaderboards work is already done, so you can use blueprints if you want to. It’s what I am doing.

There is an issue however, where the Steamworks stats are added to the previous files. Think of it like 100 steps walked, and then you tell steam to write 10 steps, so it’s 110. Rather than writing 100 score points, and then writing 80 score points, but it’s lower than 100, so it’s not written. And if it’s 113, then the new value is 113. To fix that, you must compile your own version of the engine, and follow this guide.
https://lordihean.net/2016/04/21/ue4-tutorial-resolving-steam-leaderboards/

EDIT. I haven’t tried yet, but after looking at the steamworks decoumentation. The step by step, could be done as a blueprint library, where you create those functions listed on the documentation and then call them. For example,

UFUNCTION(BlueprintPure, Category = "Steamworks")
bool  UYourGameBluepriontLibrary::UploadScore( int score ) { ... }

I am unaware, as it’s beyond my abilities. But I am guessing, that if you are making your game in full C++, then instead of it being a blueprint library, it would just be a library of functions that then your c++ calls to.

where does stuff like SteamAPI_Init() go into?
SteamAPI_Init() is a function that returns true if the user is properly connected to Steam. It’s done to verify in an if statement that the player is a valid steam user.