Stats #

Read more about the Stats system in Hiro here.

Get all stats #

Get all stats.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
FHiroOnStatsGet OnStatsGet;
OnStatsGet.AddDynamic(this, &AMyActor::OnStatsGet);
FOnError OnError;

HiroClient->StatsGet(Session, OnStatsGet, OnError);

void AMyActor::OnStatsGet(const FHiroStatList& StatList)
{
    UE_LOG(LogTemp, Log, TEXT("%s"), *StatList.ToJson());
}

Update stats for the player #

Update stats.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
FHiroStatUpdateRequest Request;

FHiroStatUpdate StatUpdate1;
StatUpdate1.Name = "public_stat_1";
StatUpdate1.Value = 100;
StatUpdate1.Operator = EHiroStatUpdateOperator::STAT_UPDATE_OPERATOR_SET; // Replace SomeEnumValue with the actual enum value
Request.Public.Add(StatUpdate1);

FHiroStatUpdate StatUpdate2;
StatUpdate2.Name = "private_stat_1";
StatUpdate2.Value = 100;
StatUpdate2.Operator = EHiroStatUpdateOperator::STAT_UPDATE_OPERATOR_SET; // Replace SomeEnumValue with the actual enum value
Request.Private.Add(StatUpdate2);

FHiroOnStatsUpdate OnStatsUpdate;
OnStatsUpdate.AddDynamic(this, &AMyActor::OnStatsUpdate);
FOnError OnError;

HiroClient->StatsUpdate(Session, Request, OnStatsUpdate, OnError);

void AMyActor::OnStatsUpdate(const FHiroStatList& StatList)
{
    UE_LOG(LogTemp, Log, TEXT("%s"), *StatList.ToJson());
}