Steam leaderboards add new value to existing

In OnlineLeaderboardInterfaceSteam.cpp

FOnlineAsyncTaskSteamUpdateStats::Tick

on line 293 and line 304 do an additive operation:

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

Where it should simply be:

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

this issue currently causes the wrong value to be saved in the leaderboard

Hi supagu,

I looked at the code that you are referring to and it does appear that, depending on what you are trying to accomplish, it may not do what you want. For something like a counter stat, such as total time played, this should work fine. However, if you are trying to update a list of high scores, then this wouldn’t do what you want.

Are you trying to do something like the latter?

, you are correct.
I am trying to update a high score list, which I would think would be pretty standard for a leader board.
Now, another problem I may run into is checking if the current high score exceeds the players existing leader board score.
Ideally being able to get and set stats in ue4 code would be ideal, this would eliminate any issues.
I have worked around the problem in my own code by bypassing the ue4 code and going straight to the steam code, which isn’t nice but let’s me work around the issue.

Thanks

Hi supagu,

I have submitted a report about the issue that you described (UE-24791). We will look over this segment of code again and see if it can be improved on.

Has this been fixed (and made available for Blueprint) ?

Hi motorsep,

I checked the ticket that I had entered for this issue and it is still open, so it has not been resolved yet.

Ouch :frowning:

Could you please confirm if it will be a part of 4.12 hot fix or at least fixed in 4.13 ?

Thanks

Btw, someone already proposed a working fix: https://lordihean.net/2016/04/21/ue4-tutorial-resolving-steam-leaderboards/

Shouldn’t be that hard to fix for 4.12 hotfix or at least 4.13 :slight_smile:

Hi motorsep,

I thought I had seen a Pull Request on GitHub related to this recently, but when I went looking for it today I wasn’t able to find it. I glanced over the fix proposed in the link you provided and I am not sure it would be a complete fix for all possible needs.

It does seem to solve the issue where you would need to replace a previous stat with the current stat if the current stat is larger. However, what if you wanted the stat to track the lowest value (fastest time through a level, for example), or wanted the stat to be cumulative as it is now (total time played, for example)? The proposed fix does not appear to take those options into consideration.

Just let us read the value ourselves and do the math depending on what we want, instead of forcing a default behavior that doesn’t suit most games.

The pull request I made was here https://github.com/EpicGames/UnrealEngine/pull/2498

Hi Malharhak,

Thank you for the pull request. I just wanted to let you know that we have a ticket in place to track it and we will review it when we get a .

Yeah, it’s been reviewed alright. Won’t fix. What the hell?

Hi Genova,

Thank you for letting us know that this issue is still important to you. The ticket that I had entered previously was closed due to an extended period of inactivity. I have re-opened that ticket again. The ticket for Malharhak’s pull request is still open and waiting to be reviewed.

I changed those two lines of code and re-saved the cpp file yet it’s still adding the new value to existing. I also tried restarting the editor. Am I missing something? Any help greatly appreciated!