[UE4 Tutorial] Resolving Steam Leaderboards

Greetings. I’ve discovered from one of my clients from my job that many seem to have trouble getting Steam’s leader boards to update properly via Unreal Blueprint.

If you try to use “Write Leaderboards Integer” Blueprint function right now, it will create the leader board stat but will not actually add any entries and if the stats already exist, it’ll only make blank updates – practically nothing happens.

It seems someone already discovered a solution before I did however given some are still having difficulties today I think it’s best I help shed some light on the solution with this article. So I am going to show how I (and Slimax) managed to fix this and what exactly was wrong.

First and foremost, you will obviously need a Steamworks game, if you don’t have one, this tutorial is completely useless to you. To get your game on Steamworks your game must be greenlit via Steam Greenlight than you must submit your game to Steamworks for approval via the website. I don’t own a game on Greenlight myself but my latest client from my job has one and was kind enough to allow me to use it for demonstration (with necessary censorship).

You will also have to download a custom build from the Unreal Engine GitHub then follow the instructions from there and compile the build in Visual Studio. I am trying to submit the fix to the UE GitHub repository so it will be ready by 4.12 or a quick update on 4.11 so hopefully once that’s done this tutorial will no longer be needed for that version and up.

Once that is taken cared of, go back into Visual Studio and search for “OnlineLeaderboardInterfaceSteam.cpp” and open it. This is where the leaderboard interface data is handled to acquire from and send to Steam whenever your game requires access to the leaderboards.

Go to Line 18.

Notice the “%s_%s” string. From my understanding, this is what seems to prevent the game from updating the leader boards properly. I am not sure if this is the same practice for all other leaderboard interfaces since the BP is universal and its meant to update any leaderboards it is connected to (e.g. Google  or Apple leaderboards), however apparently this practice doesn’t work well for Steamworks. So if the stat name was “Time”, it’s practically sending “Time_Time” for some odd reason. To fix this, simply replace it with “%s”. Should look like this:

Move further to Line 289 (might vary on your end) and you will find this code branch via the Tick() function.

Specifically look for this snippet.

bSuccess = SteamUserStatsPtr->SetStat(TCHAR_TO_UTF8(*StatName), OldValue + Value) ? true : false;

It is assuming success by inputting the stats name and value, HOWEVER it is also adding the old value to the new one. This only adds your time to your existing leaderboard entry so if the first time you spent 500 seconds during your first ‘Time’, and you spent 200 during your second ‘Time’, it will update your entry to 520 seconds total. It seems it does not handle math well with the value input when setting stats in the code, hence no entry at all. But I don’t think that’s what one would want with their game’s leader board anyway. If I recall, it was meant for trying to beat others original score; beating the previous record. So what should be done is deny entry until the new entry (Value) exceeds the previous one (OldValue).

if (OldValue < Value)
bSuccess = SteamUserStatsPtr->SetStat(TCHAR_TO_UTF8(*StatName), Value) ? true : false;

Should look more like this:

Finally, compile your build and test it in game. Here’s my layout if you need it.

The leader boards should finally show entries and update the stats properly.

…But if you’re in a hurry and can’t really spend the 20-40 minutes to set this up manually, you can download the file here.

Hope this all helps, meanwhile support us through social media and keep track of our website for more tutorials and other goods.

Fan us on Facebook

Establish. Explore. Expand.

The TRUE Fate of Army Men and Future of Neotl Empire.

Greetings folks! Lord Iheanacho here!

I’ve uploaded a video today explaining what is to come from us, including Army Men III’s true status (no, it’s not really dead), and future plans of Neotl Empire and it’s YouTube channel. You can watch it below.

To summarize, Army Men III is postponed and we are focusing on Army Men Online from now on. However for now, Army Men Extended is on hiatus as well until we can settle the copyright issue once and for all. The reason behind this is because we can’t distribute the game effectively without it. A C&D letter is one thing (barely an issue for our case), but we can’t get the game distributed on platforms like Steam Greenlight or possibly even the 8th gen consoles.

So our new goal right now is to start small; I am working on a new indie game.

Can’t announce the title yet as trademark is still a concern and a process I need to complete, as well as register my team as a company brand. Given the short scope of it, I will work on this game entirely alone (it’s what I know best after all).

I also want to use our YouTube channel as a basis for tutorials in game dev and perhaps other endeavors such as music composition, art, and animation. This is something I already planned years ago when UDK was popular, however I lacked the time to do it and now I missed the spotlight for UDK as it’s community is now a ghost town since UE4 became free. Now that I am done with college, I finally have the chance to get started. My tutorials will not be limited to Unreal Engine 4 however. I want to expand to other engines as well. I’ve invested some time with Unity & LumberYard lately and I am amazed to what has come with the engines, and I am eager to give Source 2.a try upon it’s release. Speaking of Source, I will also go back to using Source Engine in the meantime and even give Source Filmmaker a try..

That’s all for now, Lord Iheanacho signing off.

Establish. Explore. Expand.