What is the work flow for accessing Steam Achievements in C++? Partial Success, Need Help

Dear Friends at Epic (and Josh) :slight_smile:

What is the work flow for accessing Steam achievements?

I copied over the code from TesthAchievementsInterface

I know I have steam working because I see the in-game overlay.

I also know I am accessing the player ID correctly because my steam name shows up in the logs

#Context / Steam Serverside

Solus has an official AppID, and I have added achievements to the Solus App interface, server side, including stats, pictures, and descriptions

#Config File

I also read from the log I had to add achievements to the config file, so I did so

[OnlineSubsystemSteam]
bEnabled=true
SteamDevAppId = ######         ;Solus app ID (hidden for public display) !
GameServerQueryPort=27015
bRelaunchInSteam=false
GameVersion=1.0.0.0
bVACEnabled=1
bAllowP2PPacketRelay=true
P2PConnectionTimeout=90
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Achievement_0_Id="A_SOLUS_PDA1"
Achievement_1_Id=""
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Solus has its app ID set in the DefaultEngine config file properly.

#BP

I am running C++ code as well as the BP node to cache achievements and they are both not succeeding in reading achievements.

#Logs

Here is what my logs are saying when I am trying to read achievements:

LogOnline:Warning: STEAM: Failed to obtain steam user stats, user: Teotl_Rama [0x11000010AF40B49] has no stats entries

LogOnline:Warning: Async task 'FOnlineAsyncTaskSteamGetAchievements bWasSuccessful: 0 UserId: Teotl_Rama [0x11000010AF40B49]' completed in 0.338824 seconds with 0

LogOnline:Warning: STEAM: GetAchievementAndUnlockTime() failed for achievement 'A_SOLUS_PDA1'

LogBlueprintUserMessages: no achievements read

LogOnline:Warning: STEAM: Failed to obtain steam user stats, user: Teotl_Rama [0x11000010AF40B49] has no stats entries

LogOnline:Warning: Async task 'FOnlineAsyncTaskSteamGetAchievements bWasSuccessful: 0 UserId: Teotl_Rama [0x11000010AF40B49]' completed in 0.678597 seconds with 0

LogOnline:Warning: STEAM: GetAchievementAndUnlockTime() failed for achievement 'A_SOLUS_PDA1'

SolusLog:Display: ASolusSteam::OnQueryAchievementsComplete
SolusLog:Display: TEST FAILED: Failed to Load Achievements

#User Has No Stats Entries

What does this log error mean?

The user name I am using has access to Solus App and can add stuff, do I need to do some extra step to ensure this steam user name has stats for the game / owns the game?

#steam_appid.txt

Do I need to change the steam_appid.txt somewheres to match the App ID for Solus? Is changing the App ID in the config file sufficient, as shown above?

EDIT : Nevermind, I have confirmed that once the game starts running, when I go to Engine/Binaries/Win64, steam_appid.txt is there, and it does show Solus’s steam app id!

#Thanks!

Thanks for any assistance in advance!

I am not sure what step I am missing here to get my first test achievement to be detected properly!

I’ve done

  • Steam App server side
  • config file locally matches server side name
  • steam is working

Please do let me know any missings steps!

Rama

#C++ Code For Reference

I just copied it right over, but here is the relevant code for reference:

As you can see from my log above I am succeeding in getting the correct user ID passed into the system.

void ASolusSteam::GetAchievementsFromOnlineSubsystem()
{
	// Add our delegate and read achievements
	OnlineAchievements->QueryAchievements( *UserId.Get(), FOnQueryAchievementsCompleteDelegate::CreateUObject(this, &ASolusSteam::OnQueryAchievementsComplete ) );
}

  
void ASolusSteam::OnQueryAchievementsComplete(const FUniqueNetId& PlayerId, const bool bWasSuccessful)
{
	UE_LOG(SolusLog, Display, TEXT("ASolusSteam::OnQueryAchievementsComplete"));

	if (bWasSuccessful)
	{
		UE_LOG(SolusLog, Display, TEXT("Loaded Achievements"));

		TArray<FOnlineAchievement> PlayerAchievements;
		if (OnlineAchievements->GetCachedAchievements(*UserId.Get(), PlayerAchievements) != EOnlineCachedResult::Success || PlayerAchievements.Num() == 0)
		{
			UE_LOG(SolusLog, Warning, TEXT("TEST FAILED: Either GetCachedAchievements() failed or number of achievements is 0"));
			return;
		}

		UE_LOG(SolusLog, Display, TEXT("Number of Achievements: %d"), PlayerAchievements.Num());
		for(int32 Idx = 0; Idx < PlayerAchievements.Num(); ++Idx)
		{
			UE_LOG(SolusLog, Display, TEXT(" Achievement %d: %s"), Idx, *PlayerAchievements[ Idx ].ToDebugString());
		}

		QueryAchievementDescriptions( PlayerId );
	}
	else
	{ 
		// if our test failed, be sure to clean itself up
		UE_LOG(SolusLog, Display, TEXT("TEST FAILED: Failed to Load Achievements"));
	}
}

#Success!

The step I was missing is that I had to publish changes on the Steam App after adding all the achievements.

Once I published the changes the above error messages went away, replaced by this!

Yay!

Rama