Event Leaderboards #

Read more about the Event Leaderboards system in Hiro here.

Get an event leaderboard #

Get a specified event leaderboard defined for the game.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
FHiroEventLeaderboardGet Request;
Request.Id = TEXT("leaderboard_1");

FHiroOnEventLeaderboardGet OnEventLeaderboardGet;
OnEventLeaderboardGet.AddDynamic(this, &AMyActor::OnEventLeaderboardGet);
FOnError OnError;

HiroClient->EventLeaderboardGet(Session, Request, OnEventLeaderboardGet, OnError);

void AMyActor::OnEventLeaderboardGet(const FHiroEventLeaderboard& EventLeaderboard)
{
    UE_LOG(LogTemp, Log, TEXT("%s"), *EventLeaderboard.ToJson());
}

Update event leaderboard record #

Update an event leaderboard record for a user.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
FHiroEventLeaderboardUpdate Request;
Request.Id = TEXT("leaderboard_1");
Request.Score = 100;
Request.Subscore = 10;

FHiroOnEventLeaderboardUpdate OnEventLeaderboardUpdate;
OnEventLeaderboardUpdate.AddDynamic(this, &AMyActor::OnEventLeaderboardUpdate);
FOnError OnError;

HiroClient->EventLeaderboardUpdate(Session, Request, OnEventLeaderboardUpdate, OnError);

void AMyActor::OnEventLeaderboardUpdate(const FHiroEventLeaderboard& EventLeaderboard)
{
    UE_LOG(LogTemp, Log, TEXT("%s"), *EventLeaderboard.ToJson());
}

Claim event leaderboard reward #

Claim an event leaderboard reward for a user.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
FHiroEventLeaderboardClaim Request;
Request.Id = TEXT("leaderboard_1");

FHiroOnEventLeaderboardClaim OnEventLeaderboardClaim;
OnEventLeaderboardClaim.AddDynamic(this, &AMyActor::OnEventLeaderboardClaim);
FOnError OnError;

HiroClient->EventLeaderboardClaim(Session, Request, OnEventLeaderboardClaim, OnError);

void AMyActor::OnEventLeaderboardClaim(const FHiroEventLeaderboard& EventLeaderboard)
{
    UE_LOG(LogTemp, Log, TEXT("%s"), *EventLeaderboard.ToJson());
}

Roll a new cohort #

Roll a new cohort for the specified event leaderboard.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
FHiroEventLeaderboardRoll Request;
Request.Id = TEXT("leaderboard_1");

FHiroOnEventLeaderboardRoll OnEventLeaderboardRoll;
OnEventLeaderboardRoll.AddDynamic(this, &AMyActor::OnEventLeaderboardRoll);
FOnError OnError;

HiroClient->EventLeaderboardRoll(Session, Request, OnEventLeaderboardRoll, OnError);

void AMyActor::OnEventLeaderboardRoll(const FHiroEventLeaderboard& EventLeaderboard)
{
    UE_LOG(LogTemp, Log, TEXT("%s"), *EventLeaderboard.ToJson());
}

Debugging an event leaderboard #

You can fill an event leaderboard with dummy users and assign random scores to them for testing purposes.

This is intended for debugging use only.
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
FHiroEventLeaderboardDebugFillRequest FillRequest;
FillRequest.Id = TEXT("leaderboard_1");
FillRequest.TargetCount = 50; // Optional target cohort size to fill to, otherwise fill to the max cohort size.

FHiroEventLeaderboardDebugRandomScoresRequest ScoresRequest;
ScoresRequest.Id = TEXT("leaderboard_1");
ScoresRequest.Min = 1;
ScoresRequest.Max = 100;
ScoresRequest.SubscoreMin = 1;
ScoresRequest.SubscoreMax = 100;

FHiroOnEventLeaderboardDebugFill OnEventLeaderboardDebugFill;
OnEventLeaderboardDebugFill.AddDynamic(this, &AMyActor::OnEventLeaderboardDebugFill);
FOnError OnFillError;

FHiroOnEventLeaderboardDebugRandomScores OnEventLeaderboardDebugRandomScores;
OnEventLeaderboardDebugRandomScores.AddDynamic(this, &AMyActor::OnEventLeaderboardDebugRandomScores);
FOnError OnScoresError;

// Fills cohort with debug players
HiroClient->EventLeaderboardDebugFill(Session, FillRequest, OnEventLeaderboardDebugFill, OnFillError);

// Sets randomly generated scores between a range for other players (does not change the user's score)
HiroClient->EventLeaderboardDebugRandomScores(Session, ScoresRequest, OnEventLeaderboardDebugRandomScores, OnScoresError);

void AMyActor::OnEventLeaderboardDebugFill(const FHiroEventLeaderboard& EventLeaderboard)
{
    UE_LOG(LogTemp, Log, TEXT("%s"), *EventLeaderboard.ToJson());
}

void AMyActor::OnEventLeaderboardDebugRandomScores(const FHiroEventLeaderboard& EventLeaderboard)
{
    UE_LOG(LogTemp, Log, TEXT("%s"), *EventLeaderboard.ToJson());
}