Hi,
I have been digging this for days but I can’t seems to get it work.
First I am kind of beginner in C++ programming and leaderboards management seems to be a quite complex feature to handle. I tried to understand leaderboards in ShooterGame source code and my main goal is to make use of this function :
virtual bool ReadLeaderboardsAroundUser(TSharedRef<const FUniqueNetId> Player, uint32 Range, FOnlineLeaderboardReadRef& ReadObject) = 0;
To simply get Steam leaderboards of people around the user and expose it to Blueprint.
So far I’ve written this function :
int32 UZombieSteamworks::GetPlayerScore()
{
//Get the online sub system
IOnlineSubsystem* OnlineSub = IOnlineSubsystem::Get();
if (OnlineSub)
{
//Get the Identity from the sub system
//Meaning our player's profile and various online services
IOnlineIdentityPtr Identity = OnlineSub->GetIdentityInterface();
if (Identity.IsValid())
{
//Get a thread-safe pointer
TSharedPtr<const FUniqueNetId> UserIdPtr = Identity->GetUniquePlayerId(0);
TSharedRef<const FUniqueNetId> UserIdRef = UserIdPtr.ToSharedRef();
IOnlineLeaderboardsPtr Leaderboards = OnlineSub->GetLeaderboardsInterface();
if (Leaderboards.IsValid())
{
//Make a shared pointer for leaderboards reading
FOnlineLeaderboardReadPtr LeaderboardReadPtr = MakeShareable(new ZombieSteamWorksLeaderboardRead());
FOnlineLeaderboardReadRef LeaderboardReadRef = LeaderboardReadPtr.ToSharedRef();
bool HasReadLeaderboard = Leaderboards->ReadLeaderboardsAroundUser(UserIdRef, 2, LeaderboardReadRef);
if (HasReadLeaderboard)
{
TSharedPtr<FLeaderboardRow> NewLeaderboardRow = MakeShareable(new FLeaderboardRow(LeaderboardReadRef->Rows[0]));
return 1;
//return LeaderboardReadRef->Rows.Lenght;
//if (LeaderboardReadRef->Rows[0] != NULL)
//{
//return LeaderboardReadRef->Rows[0].Rank;
//}
}
}
}
}
return 0;
}
This code will compile fine but will crash the game when trying to access value of LeaderboardReadRef->Rows.
How is one able to get Steam leaderboard and how does OnlineLeaderboardInteface works ?
I do have Leaderboard working on Steamworks web API with a name and scores stored from the player but where would I reference in the code.