Advanced Steam Sessions - Online State is empty

Hi, I have a problem to check my friends online status using Advanced Steam Sessions. I can host and join to my friends but when I try to check their online status, it seems like it was empty (I have tried to print this and when I remove “Switch on EBPOnlinePresenceState” everything works fine).

Steam overlay is active, I’m using test steam app id, I have copied this into DefaultEngine.ini:

[/Script/Engine.GameEngine]
+NetDriverDefinitions=(DefName="GameNetDriver",DriverClassName="OnlineSubsystemSteam.SteamNetDriver",DriverClassNameFallback="OnlineSubsystemUtils.IpNetDriver")

[OnlineSubsystem]
DefaultPlatformService=Steam

[OnlineSubsystemSteam]
bEnabled=true
SteamDevAppId=480

; If using Sessions
; bInitServerOnClient=true

[/Script/OnlineSubsystemSteam.SteamNetDriver]
NetConnectionClassName="OnlineSubsystemSteam.SteamNetConnection"

I have active plugins like: Advanced Steam Sessions, Advanced Sessions, Online Subsystem, Online Subsystem Steam

It happeds only when I build and package my project to .exe file. In editor everything works fine.

This is how I did it in my game, and it worked quite fine. You can try it in your C++.

void UEosHelper::GetFriendInfoFromList(const int32 LocalPlayerId, const FString& UniqueNetId)
{
	if (OnlineSubsystem)
	{
		const IOnlineFriendsPtr FriendsInterface = OnlineSubsystem->GetFriendsInterface();
		const TSharedPtr<const FUniqueNetId> NetId = CreateUniqueIdFromString(UniqueNetId);
		if (FriendsInterface != nullptr && FriendsInterface.IsValid() && NetId.IsValid())
		{
			const TSharedPtr<FOnlineFriend> Friend = FriendsInterface->GetFriend(LocalPlayerId, *NetId, FriendListName);

			const bool IsPlayingTheSameGame = Friend->GetPresence().bIsPlayingThisGame;
			const FOnlineUserPresenceStatus OnlineStatus = Friend->GetPresence().Status;
			switch (OnlineStatus.State)
			{
			case EOnlinePresenceState::Away:
				break;
			case EOnlinePresenceState::Chat:
				break;
			case EOnlinePresenceState::Offline:
				break;
			case EOnlinePresenceState::Online:
				break;
			case EOnlinePresenceState::ExtendedAway:
				break;
			case EOnlinePresenceState::DoNotDisturb:
				break;
				default: {}
			}
		}
	}
}

You can now create your own struct to handle return value, and here is how it is in my game.

.h file

USTRUCT(BlueprintType)
struct FFriendListInfo
{
	GENERATED_USTRUCT_BODY()
	
	UPROPERTY(EditAnywhere, BlueprintReadWrite)
	EFriendOnlineStatus PlayerOnlineState;

	UPROPERTY(EditAnywhere, BlueprintReadWrite)
	bool PlayingSameGame;	
};

UENUM(BlueprintType)
enum class EFriendOnlineStatus : uint8
{
	Online,
	Offline,
	Away,
	ExtendedAway,
	DoNotDisturb,
	Chat,
	Unknown
};

UFUNCTION(BlueprintPure)
	FFriendListInfo GetFriendInfoFromList(const int32 LocalPlayerId, const FString& UniqueNetId);

.cpp

FFriendListInfo UEosHelper::GetFriendInfoFromList(const int32 LocalPlayerId, const FString& UniqueNetId)
{
	if (OnlineSubsystem)
	{
		const IOnlineFriendsPtr FriendsInterface = OnlineSubsystem->GetFriendsInterface();
		const TSharedPtr<const FUniqueNetId> NetId = CreateUniqueIdFromString(UniqueNetId);
		if (FriendsInterface != nullptr && FriendsInterface.IsValid() && NetId.IsValid())
		{
			const TSharedPtr<FOnlineFriend> Friend = FriendsInterface->GetFriend(LocalPlayerId, *NetId, FriendListName);

			const bool IsPlayingTheSameGame = Friend->GetPresence().bIsPlayingThisGame;
			const FOnlineUserPresenceStatus OnlineStatus = Friend->GetPresence().Status;
			EFriendOnlineStatus ConvertedStatus;
			switch (OnlineStatus.State)
			{
			case EOnlinePresenceState::Away:
				ConvertedStatus = EFriendOnlineStatus::Away;
				break;
			case EOnlinePresenceState::Chat:
				ConvertedStatus = EFriendOnlineStatus::Chat;
				break;
			case EOnlinePresenceState::Offline:
				ConvertedStatus = EFriendOnlineStatus::Offline;
				break;
			case EOnlinePresenceState::Online:
				ConvertedStatus = EFriendOnlineStatus::Online;
				break;
			case EOnlinePresenceState::ExtendedAway:
				ConvertedStatus = EFriendOnlineStatus::ExtendedAway;
				break;
			case EOnlinePresenceState::DoNotDisturb:
				ConvertedStatus = EFriendOnlineStatus::DoNotDisturb;
				break;
				default:
					ConvertedStatus = EFriendOnlineStatus::Unknown;
			}

			FFriendListInfo FriendListInfo;
			FriendListInfo.PlayerOnlineState = ConvertedStatus;
			FriendListInfo.PlayingSameGame = IsPlayingTheSameGame;
			return FriendListInfo;
		}
	}

	FFriendListInfo FriendListInfo;
	FriendListInfo.PlayerOnlineState = EFriendOnlineStatus::Unknown;
	FriendListInfo.PlayingSameGame = false;
	return FriendListInfo;
}

Thank you for yor reply, but I get crash of my friends list when I tried to adjust your code to my project:


MyActor.h

#pragma once

#include "CoreMinimal.h"
#include "GameFramework/Actor.h"
#include "MyActor.generated.h"

UENUM(BlueprintType)
enum class EFriendOnlineStatus : uint8
{
	Online,
	Offline,
	Away,
	ExtendedAway,
	DoNotDisturb,
	Chat,
	Unknown
};

USTRUCT(BlueprintType)
struct FFriendListInfo
{
	GENERATED_BODY()

	UPROPERTY(EditAnywhere, BlueprintReadWrite)
	EFriendOnlineStatus PlayerOnlineState;

	UPROPERTY(EditAnywhere, BlueprintReadWrite)
	bool PlayingSameGame;
};

UCLASS(Blueprintable, BlueprintType)
class MULTIPLAYER_API AMyActor : public AActor
{
	GENERATED_BODY()
	
public:	
	// Sets default values for this actor's properties
	AMyActor();

protected:
	// Called when the game starts or when spawned
	virtual void BeginPlay() override;

public:	
	// Called every frame
	virtual void Tick(float DeltaTime) override;

public:
	UFUNCTION(BlueprintPure)
	FFriendListInfo GetFriendInfoFromList(const int32 LocalPlayerId, const FString& UniqueNetId);

};

MyActor.cpp

#include "MyActor.h"
#include "OnlineSubsystem.h"
#include "AdvancedFriendsLibrary.h"
#include "AdvancedSteamFriendsLibrary.h"
#include <OnlineSubsystemUtils.h>

// Sets default values
AMyActor::AMyActor()
{
 	// Set this actor to call Tick() every frame.  You can turn this off to improve performance if you don't need it.
	PrimaryActorTick.bCanEverTick = true;

}

// Called when the game starts or when spawned
void AMyActor::BeginPlay()
{
	Super::BeginPlay();
}

// Called every frame
void AMyActor::Tick(float DeltaTime)
{
	Super::Tick(DeltaTime);

}

FFriendListInfo AMyActor::GetFriendInfoFromList(const int32 LocalPlayerId, const FString& UniqueNetId)
{
	IOnlineSubsystem* OnlineSubsystem = IOnlineSubsystem::Get();
	
	if (OnlineSubsystem)
	{
		const IOnlineFriendsPtr FriendsInterface = OnlineSubsystem->GetFriendsInterface();
		const TSharedPtr<const FUniqueNetId> NetId = OnlineSubsystem->GetIdentityInterface()->CreateUniquePlayerId(UniqueNetId);
		const FString FriendListName = TEXT("Default");
		if (FriendsInterface != nullptr && FriendsInterface.IsValid() && NetId.IsValid())
		{
			const TSharedPtr<FOnlineFriend> Friend = FriendsInterface->GetFriend(LocalPlayerId, *NetId, FriendListName);

			const bool IsPlayingTheSameGame = Friend->GetPresence().bIsPlayingThisGame;
			const FOnlineUserPresenceStatus OnlineStatus = Friend->GetPresence().Status;
			EFriendOnlineStatus ConvertedStatus;
			switch (OnlineStatus.State)
			{
			case EOnlinePresenceState::Away:
				ConvertedStatus = EFriendOnlineStatus::Away;
				break;
			case EOnlinePresenceState::Chat:
				ConvertedStatus = EFriendOnlineStatus::Chat;
				break;
			case EOnlinePresenceState::Offline:
				ConvertedStatus = EFriendOnlineStatus::Offline;
				break;
			case EOnlinePresenceState::Online:
				ConvertedStatus = EFriendOnlineStatus::Online;
				break;
			case EOnlinePresenceState::ExtendedAway:
				ConvertedStatus = EFriendOnlineStatus::ExtendedAway;
				break;
			case EOnlinePresenceState::DoNotDisturb:
				ConvertedStatus = EFriendOnlineStatus::DoNotDisturb;
				break;
			default:
				ConvertedStatus = EFriendOnlineStatus::Unknown;
			}

			FFriendListInfo FriendListInfo;
			FriendListInfo.PlayerOnlineState = ConvertedStatus;
			FriendListInfo.PlayingSameGame = IsPlayingTheSameGame;
			return FriendListInfo;
		}
	}

	FFriendListInfo FriendListInfo;
	FriendListInfo.PlayerOnlineState = EFriendOnlineStatus::Unknown;
	FriendListInfo.PlayingSameGame = false;
	return FriendListInfo;
}

I don’t get any errors and I use UE version 5.4.1

You need to tell me what is the crash, so that I can help.

Ok, I tried to make it simple and figure it out what is the problem. I have an idea to just get a friend instance and return true if he’s Online. However I can’t include AdvancedFriendsLibrary.h in .h files, but in .cpp files it is possible.

I get an error: Unable to find ‘class’, ‘delegate’, ‘enum’, or ‘struct’ with name ‘FOnlineFriend’

and this warning:

Multiplayer.uproject does not list plugin ‘OnlineSubsystemSteam’ as a dependency, but module ‘Multiplayer’ depends on ‘OnlineSubsystemSteam’.

I have a simple class:
MyBlueprintFunctionLibrary.h

#pragma once

#include "CoreMinimal.h"
#include "Kismet/BlueprintFunctionLibrary.h"

#include "AdvancedFriendsLibrary.h" //<--- this cannot be included for some reason
#include "MyBlueprintFunctionLibrary.generated.h"

UCLASS()
class MULTIPLAYER_API UMyBlueprintFunctionLibrary : public UBlueprintFunctionLibrary
{
	GENERATED_BODY()

public:
    UFUNCTION(BlueprintCallable, Category = "Online|Presence")
    static bool GetFriendPresenceStatus(const FOnlineFriend& Friend);
};

MyBlueprintFunctionLibrary.cpp

#include "MyBlueprintFunctionLibrary.h"

bool UMyBlueprintFunctionLibrary::GetFriendPresenceStatus(const FOnlineFriend& Friend)
{
	const FOnlineUserPresenceStatus OnlineStatus = Friend.GetPresence().Status;
	switch (OnlineStatus.State)
	{
	case EOnlinePresenceState::Online:
		return true;
	}
	return false;
}

My .Build.cs file:

using UnrealBuildTool;

public class Multiplayer : ModuleRules
{
	public Multiplayer(ReadOnlyTargetRules Target) : base(Target)
	{
		PCHUsage = PCHUsageMode.UseExplicitOrSharedPCHs;

		PublicDependencyModuleNames.AddRange(new string[] { "Core", "CoreUObject", "Engine", "InputCore", "EnhancedInput" , "AdvancedSessions", "AdvancedSteamSessions" });

		PrivateDependencyModuleNames.AddRange(new string[] { "OnlineSubsystem", "OnlineSubsystemNull", "OnlineSubsystemSteam"});
	}
}

.Target.cs

using UnrealBuildTool;
using System.Collections.Generic;

public class MultiplayerTarget : TargetRules
{
	public MultiplayerTarget(TargetInfo Target) : base(Target)
	{
		Type = TargetType.Game;
		DefaultBuildSettings = BuildSettingsVersion.V5;
		IncludeOrderVersion = EngineIncludeOrderVersion.Unreal5_4;
		
		bUsesSteam = true;

		ExtraModuleNames.Add("Multiplayer");
	}
}

I also copied OnlineSubsystemSteam into my plugins folder and rebuild an entire project.
image

Let me know if you need more information.

EDIT:
I changed code to use # include AdvancedFriendsLibrary.h just in .cpp file, removed warning by adding to my .uproject:

{
		"Name": "OnlineSubsystemSteam",
		"Enabled": true
}

But I get unknown function error:

LogPlayLevel: Error: UAT: [2024.05.29-00.09.57:566][ 1]LogWindows: Error: begin: stack for UAT
LogPlayLevel: Error: UAT: [2024.05.29-00.09.57:566][ 1]LogWindows: Error: === Critical error: ===
LogPlayLevel: Error: UAT: [2024.05.29-00.09.57:566][ 1]LogWindows: Error:
LogPlayLevel: Error: UAT: [2024.05.29-00.09.57:566][ 1]LogWindows: Error: Fatal error!
LogPlayLevel: Error: UAT: [2024.05.29-00.09.57:566][ 1]LogWindows: Error:
LogPlayLevel: Error: UAT: [2024.05.29-00.09.57:566][ 1]LogWindows: Error: Unhandled Exception: EXCEPTION_ACCESS_VIOLATION reading address 0xffffffffffffffff
LogPlayLevel: Error: UAT: [2024.05.29-00.09.57:566][ 1]LogWindows: Error:
LogPlayLevel: Error: UAT: [2024.05.29-00.09.57:568][ 1]LogWindows: Error: [Callstack] 0x00007ff916ef123d VCRUNTIME140.dll!UnknownFunction
LogPlayLevel: Error: UAT: [2024.05.29-00.09.57:568][ 1]LogWindows: Error: [Callstack] 0x00007ff6ff3d4056 Multiplayer.exe!FString::FString()
LogPlayLevel: Error: UAT: [2024.05.29-00.09.57:568][ 1]LogWindows: Error: [Callstack] 0x00007ff70718dbfc Multiplayer.exe!UMyBlueprintFunctionLibrary::GetFriendPresenceStatus() [E:\UE_5.4\Projekty\Multiplayer\Source\Multiplayer\MyBlueprintFunctionLibrary.cpp:27]
LogPlayLevel: Error: UAT: [2024.05.29-00.09.57:568][ 1]LogWindows: Error: [Callstack] 0x00007ff70718add7 Multiplayer.exe!UMyBlueprintFunctionLibrary::execGetFriendPresenceStatus() [E:\UE_5.4\Projekty\Multiplayer\Intermediate\Build\Win64\UnrealGame\Inc\Multiplayer\UHT\MyBlueprintFunctionLibrary.gen.cpp:71]
LogPlayLevel: Error: UAT: [2024.05.29-00.09.57:568][ 1]LogWindows: Error: [Callstack] 0x00007ff70010c8d8 Multiplayer.exe!UObject::execCallMathFunction()
LogPlayLevel: Error: UAT: [2024.05.29-00.09.57:568][ 1]LogWindows: Error: [Callstack] 0x00007ff70010ee2d Multiplayer.exe!UObject::execLetBool()
LogPlayLevel: Error: UAT: [2024.05.29-00.09.57:568][ 1]LogWindows: Error: [Callstack] 0x00007ff7000e1748 Multiplayer.exe!ProcessLocalScriptFunction()
LogPlayLevel: Error: UAT: [2024.05.29-00.09.57:568][ 1]LogWindows: Error: [Callstack] 0x00007ff7000b8f75 Multiplayer.exe!ProcessScriptFunction<void (__cdecl*)(UObject * __ptr64,FFrame & __ptr64,void * __ptr64)>()
LogPlayLevel: Error: UAT: [2024.05.29-00.09.57:568][ 1]LogWindows: Error: [Callstack] 0x00007ff7000e128e Multiplayer.exe!ProcessLocalFunction()
LogPlayLevel: Error: UAT: [2024.05.29-00.09.57:568][ 1]LogWindows: Error: [Callstack] 0x00007ff7000e1748 Multiplayer.exe!ProcessLocalScriptFunction()
LogPlayLevel: Error: UAT: [2024.05.29-00.09.57:568][ 1]LogWindows: Error: [Callstack] 0x00007ff7000e096c Multiplayer.exe!UObject::ProcessInternal()
LogPlayLevel: Error: UAT: [2024.05.29-00.09.57:568][ 1]LogWindows: Error: [Callstack] 0x00007ff6ffde7669 Multiplayer.exe!UFunction::Invoke()
LogPlayLevel: Error: UAT: [2024.05.29-00.09.57:568][ 1]LogWindows: Error: [Callstack] 0x00007ff7000df5da Multiplayer.exe!UObject::ProcessEvent()
LogPlayLevel: Error: UAT: [2024.05.29-00.09.57:568][ 1]LogWindows: Error: [Callstack] 0x00007ff7000b8774 Multiplayer.exe!TMulticastScriptDelegate::ProcessMulticastDelegate()
LogPlayLevel: Error: UAT: [2024.05.29-00.09.57:568][ 1]LogWindows: Error: [Callstack] 0x00007ff7070df7b4 Multiplayer.exe!FBlueprintGetFriendsListDelegate_DelegateWrapper() [E:\UE_5.4\Projekty\Multiplayer\Plugins\AdvancedSessions\Intermediate\Build\Win64\UnrealGame\Inc\AdvancedSessions\UHT\GetFriendsCallbackProxy.gen.cpp:68]
LogPlayLevel: Error: UAT: [2024.05.29-00.09.57:568][ 1]LogWindows: Error: [Callstack] 0x00007ff7070f712e Multiplayer.exe!UGetFriendsCallbackProxy::OnReadFriendsListCompleted() [E:\UE_5.4\Projekty\Multiplayer\Plugins\AdvancedSessions\Source\AdvancedSessions\Private\GetFriendsCallbackProxy.cpp:107]
LogPlayLevel: Error: UAT: [2024.05.29-00.09.57:568][ 1]LogWindows: Error: [Callstack] 0x00007ff7070f688b Multiplayer.exe!TBaseUObjectMethodDelegateInstance<0,UGetFriendsCallbackProxy,void __cdecl(int,bool,FString const &,FString const &),FDefaultDelegateUserPolicy>::ExecuteIfSafe() [E:\UE_5.4\Engine\Source\Runtime\Core\Public\Delegates\DelegateInstancesImpl.h:667]
LogPlayLevel: Error: UAT: [2024.05.29-00.09.57:568][ 1]LogWindows: Error: [Callstack] 0x00007ff70706dcaf Multiplayer.exe!FOnlineAsyncTaskSteamReadFriendsList::TriggerDelegates() [E:\UE_5.4\Projekty\Multiplayer\Plugins\Online\OnlineSubsystemSteam\Source\Private\OnlineFriendsInterfaceSteam.cpp:336]
LogPlayLevel: Error: UAT: [2024.05.29-00.09.57:568][ 1]LogWindows: Error: [Callstack] 0x00007ff706eaa8fd Multiplayer.exe!FOnlineAsyncTaskManager::GameTick()
LogPlayLevel: Error: UAT: [2024.05.29-00.09.57:568][ 1]LogWindows: Error: [Callstack] 0x00007ff7070ba800 Multiplayer.exe!FOnlineSubsystemSteam::Tick() [E:\UE_5.4\Projekty\Multiplayer\Plugins\Online\OnlineSubsystemSteam\Source\Private\OnlineSubsystemSteam.cpp:378]
LogPlayLevel: Error: UAT: [2024.05.29-00.09.57:568][ 1]LogWindows: Error: [Callstack] 0x00007ff6ff484185 Multiplayer.exe!TBaseRawMethodDelegateInstance<0,FTSTickerObjectBase,bool __cdecl(float),FDefaultDelegateUserPolicy>::Execute()
LogPlayLevel: Error: UAT: [2024.05.29-00.09.57:569][ 1]LogWindows: Error: [Callstack] 0x00007ff6ff4ac813 Multiplayer.exe!FTSTicker::Tick()
LogPlayLevel: Error: UAT: [2024.05.29-00.09.57:569][ 1]LogWindows: Error: [Callstack] 0x00007ff706dea75f Multiplayer.exe!FEngineLoop::Tick()
LogPlayLevel: Error: UAT: [2024.05.29-00.09.57:569][ 1]LogWindows: Error: [Callstack] 0x00007ff706e00d0c Multiplayer.exe!GuardedMain()
LogPlayLevel: Error: UAT: [2024.05.29-00.09.57:569][ 1]LogWindows: Error: [Callstack] 0x00007ff706e00dda Multiplayer.exe!GuardedMainWrapper()
LogPlayLevel: Error: UAT: [2024.05.29-00.09.57:569][ 1]LogWindows: Error: [Callstack] 0x00007ff706e039a5 Multiplayer.exe!LaunchWindowsStartup()
LogPlayLevel: Error: UAT: [2024.05.29-00.09.57:569][ 1]LogWindows: Error: [Callstack] 0x00007ff706e14004 Multiplayer.exe!WinMain()
LogPlayLevel: Error: UAT: [2024.05.29-00.09.57:569][ 1]LogWindows: Error: [Callstack] 0x00007ff70ae1b95a Multiplayer.exe!__scrt_common_main_seh() [D:\a_work\1\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl:288]
LogPlayLevel: Error: UAT: [2024.05.29-00.09.57:569][ 1]LogWindows: Error: [Callstack] 0x00007ff93bca257d KERNEL32.DLL!UnknownFunction
LogPlayLevel: Error: UAT: [2024.05.29-00.09.57:570][ 1]LogWindows: Error:
LogPlayLevel: Error: UAT: [2024.05.29-00.09.57:570][ 1]LogWindows: Error: end: stack for UAT

This is a typical Null pointer exception. Check your MyBlueprintFunctionLibrary and line 71. This is whre it happens.

Also, can you take a look at this video?

Maybe you are doing it too early. You need to wait for login to complete in order to request friends list. There is much more to cover there.

I get this error when I try to get online status in switch statement

const FOnlineUserPresenceStatus OnlineStatus = Friend.GetPresence().Status; // OK

switch (OnlineStatus.State) //CRASH
{
    case EOnlinePresenceState::Online:
    return true;
}

I don’t need to login in advanced steam sessions, I have to only create a session (as far I know). I watched this and previous tutorials but I don’t even have these data for login in steam.

It happends only when I try to build project. In standalone everything works.

You don’t need to login to Advanced Sessions, but you cannot ask fro friends list if Online Subsystem is not initialized and if you are not yet logged in.

I use this code to check when I’m logged in (my class is UEosHelper)

		const IOnlineIdentityPtr Identity = OnlineSubsystem->GetIdentityInterface();
				
		if (Identity != nullptr)
		{
			Identity->OnLoginCompleteDelegates->AddUObject(this, &UEosHelper::OnLoginComplete);
			Identity->AutoLogin(0);
		}

function

void UEosHelper::OnLoginComplete(int32 LocalPlayerNum, bool Success, const FUniqueNetId& ID, const FString& Message)

Then you can request friends list. In your case OnlineStatus is null and therefore you get NPE.

Btw, I am not sure if this could be the issue for you, buuuut, I remember I had to request user info before requesting any info. So after I log in I do this:

void USteamHelper::RequestFriendsInfo(const FString& UniqueNetId)
{
	if (SteamAPI_Init())
	{
		const uint64 Int64Id = FCString::Atoi64(*UniqueNetId);
		SteamFriends()->RequestUserInformation(Int64Id, false);
	}
}

For this you must have Steam_API. But again, I think you should watch the video I gave you, and try to go from scratch.

I tried to implement all of these, but I get error while compiling:

MyPlayerControllerFriends.cpp.obj : error LNK2019: unrecognized external symbol __imp_SteamAPI_GetHSteamUser referenced in a function “void __cdecl SteamInternal_Init_SteamFriends(class ISteamFriends * *)” (?SteamInternal_Init_SteamFriends@@YAXPEAPEAVISteamFriends@@@Z)
MyPlayerControllerFriends.cpp.obj : error LNK2019: unrecognized external symbol __imp_SteamInternal_ContextInit referenced in a function “public: void __cdecl AMyPlayerControllerFriends::OnGetAllFriendsComplete(int,bool,class FString const &,class FString const &)” (?OnGetAllFriendsComplete@AMyPlayerControllerFriends@@QEAAXH_NAEBVFString@@1@Z)
MyPlayerControllerFriends.cpp.obj : error LNK2019: unrecognized external symbol __imp_SteamInternal_FindOrCreateUserInterface referenced in a function “void __cdecl SteamInternal_Init_SteamFriends(class ISteamFriends * *)” (?SteamInternal_Init_SteamFriends@@YAXPEAPEAVISteamFriends@@@Z)
MyPlayerControllerFriends.cpp.obj : error LNK2019: unrecognized external symbol __imp_SteamAPI_Init referenced in a function “public: void __cdecl AMyPlayerControllerFriends::OnGetAllFriendsComplete(int,bool,class FString const &,class FString const &)” (?OnGetAllFriendsComplete@AMyPlayerControllerFriends@@QEAAXH_NAEBVFString@@1@Z)

MyPlayerControllerFriends.h

#pragma once

#include "CoreMinimal.h"
#include "GameFramework/PlayerController.h"



#include "MyPlayerControllerFriends.generated.h"

/**
 * 
 */
UCLASS()
class MULTIPLAYER_API AMyPlayerControllerFriends : public APlayerController
{
	GENERATED_BODY()

	virtual void BeginPlay() override;

public:
	void OnGetAllFriendsComplete(int32 LocalUserNum, bool bWasSuccessful, const FString& ListName,
		const FString& ErrorStr);

	void OnLoginComplete(int32 LocalPlayerNum, bool Success, const FUniqueNetId& ID, const FString& Message);

	
};

MyPlayerControllerFriends.cpp

#include "MyPlayerControllerFriends.h"
#include "AdvancedFriendsLibrary.h"
#include "AdvancedSteamFriendsLibrary.h"
#include <OnlineSubsystemUtils.h>
#include "OnlineSubsystem.h"
#include "Interfaces/OnlinePresenceInterface.h"

void AMyPlayerControllerFriends::BeginPlay()
{
	Super::BeginPlay();
	GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Yellow, TEXT("MyCustomFunction was called!"));
	IOnlineSubsystem* OnlineSubsystem = IOnlineSubsystem::Get();

	const IOnlineIdentityPtr Identity = OnlineSubsystem->GetIdentityInterface();
	if (Identity != nullptr)
	{
		Identity->OnLoginCompleteDelegates->AddUObject(this, &AMyPlayerControllerFriends::OnLoginComplete);
		Identity->AutoLogin(0);
	}

}

void AMyPlayerControllerFriends::OnGetAllFriendsComplete(int32 LocalUserNum, bool bWasSuccessful, const FString& ListName, const FString& ErrorStr)
{

	IOnlineSubsystem* OnlineSubsystem = IOnlineSubsystem::Get();
	if (bWasSuccessful) {
		if (OnlineSubsystem) {
			if (IOnlineFriendsPtr FriendsPtr = OnlineSubsystem->GetFriendsInterface()) {
				TArray<TSharedRef<FOnlineFriend>> FriendList;
				if (FriendsPtr->GetFriendsList(0, ListName, FriendList)) {

					for (TSharedRef<FOnlineFriend> Friend : FriendList) {
						TSharedPtr<const FUniqueNetId> FriendId = Friend->GetUserId();
						FString FriendIdStr = FriendId->ToString();

						if (SteamAPI_Init())
						{
							const uint64 Int64Id = FCString::Atoi64(*FriendIdStr);
							SteamFriends()->RequestUserInformation(Int64Id, false);
						}

						const FOnlineUserPresenceStatus OnlineStatus = Friend.Get().GetPresence().Status;
						if (OnlineStatus.State == EOnlinePresenceState::Online) //CRASH
							GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Yellow, TEXT("Online"));
						//UE_LOG(LogTemp, Warning, TEXT("Friend %s"), *FriendName);
					}
				}
			}
		}
	}
}

void AMyPlayerControllerFriends::OnLoginComplete(int32 LocalPlayerNum, bool Success, const FUniqueNetId& ID, const FString& Message)
{
	IOnlineSubsystem* OnlineSubsystem = IOnlineSubsystem::Get();
	const IOnlineFriendsPtr FriendsInterface = OnlineSubsystem->GetFriendsInterface();
	FriendsInterface->ReadFriendsList(0, FString(""), FOnReadFriendsListComplete::CreateUObject(this, &AMyPlayerControllerFriends::OnGetAllFriendsComplete));

	
}

SteamAPI_Init is unrecognized.

You need to add Steam SDK for this, but again. If you would just watch some videos online, like the one I sent above, you might resolve this issue without having to use Steam_API. I can’t tell from forums what migth go wrong, and sometimes it just pays off to start from scratch. There are many videos online that can help.

The only solution I see is to simply add block “on invite accept” in blueprints. After that invite someone by steam overlay (shift + tab shortcut). Thank you for your efforts, I really appreciate it :slight_smile:

1 Like

No problem. I hope you resolve it.