Hey guys,
i have a problem with my code in UE4.
I will read my friends from steam but he dont found friends…
Code:
void USteamInterface::GetFriendNames(APlayerController* PlayerController, TArray<FString> & Friends)
{
if (!PlayerController)
return;
TSharedPtr<FUniqueNetId> UniqueID = PlayerController->PlayerState->UniqueId.GetUniqueNetId();
IOnlineSubsystem* SubSys = IOnlineSubsystem::Get();
IOnlineFriendsPtr FriendSys = SubSys->GetFriendsInterface();
ULocalPlayer* LP = Cast<ULocalPlayer>(PlayerController->Player);
FriendSys->ReadFriendsList(LP->GetControllerId(), EFriendsLists::ToString(EFriendsLists::Default));
TArray<TSharedRef<FOnlineFriend>> FFriends;
if (FriendSys->GetFriendsList(LP->GetControllerId(), EFriendsLists::ToString(EFriendsLists::Default), FFriends))
{
FString NewString = FString::FromInt(Friends.Num());
GEngine->AddOnScreenDebugMessage(-1, 15.0f, FColor::Red, NewString);
for (int32 friendIdx = 0; friendIdx < FFriends.Num(); friendIdx++)
{
TSharedRef<FOnlineFriend> Friend = FFriends[friendIdx];
Friends.Add(Friend->GetDisplayName());
}
}
else
{
GEngine->AddOnScreenDebugMessage(-1, 15.0f, FColor::Red, "fail");
return;
}
}
Please help me!
- m4a_X