Achievements #

Read more about the Achievements system in Hiro here.

Get all achievements #

Get all achievements with progress accumulated by the player.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
void onAchievementsGet(const Hiro::AchievementList& achievementList)
{
    for (auto it = achievementList.achievements.begin(); it != achievementList.achievements.end(); it++)
    {
        std::cout << "Found achievement: " << it->second.name << '\n';
    }

    for (auto it = achievementList.repeatAchievements.begin(); it != achievementList.repeatAchievements.end(); it++)
    {
        std::cout << "Found repeating achievement: " << it->second.name << '\n';
    }
}

void onError(const Nakama::NError& error)
{
    std::cout << Nakama::toString(error.code) << ": " << error.message << '\n';
}

hiroClient->achievementsGet(session, onAchievementsGet, onError);

Claim achievements #

Claim one or more achievements which have completed their progress.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
void onAchievementsClaim(const Hiro::AchievementsUpdateAck& achievementsUpdateAck)
{
    for (auto it = achievementsUpdateAck.achievements.begin(); it != achievementsUpdateAck.achievements.end(); it++)
    {
        std::cout << "Found achievement: " << it->second.name << '\n';
    }

    for (auto it = achievementsUpdateAck.repeatAchievements.begin(); it != achievementsUpdateAck.repeatAchievements.end(); it++)
    {
        std::cout << "Found repeating achievement: " << it->second.name << '\n';
    }
}

void onError(const Nakama::NError& error)
{
    std::cout << Nakama::toString(error.code) << ": " << error.message << '\n';
}

Hiro::AchievementsClaimRequest request;
request.ids = {"achievement_1", "achievement_2"};
request.claimTotalReward = true;

hiroClient->achievementsClaim(session, request, onAchievementsClaim, onError);

Update achievement progress #

Update one or more achievements with the same progress amount.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
void onAchievementsUpdate(const Hiro::AchievementsUpdateAck& achievementsUpdateAck)
{
    for (auto it = achievementsUpdateAck.achievements.begin(); it != achievementsUpdateAck.achievements.end(); it++)
    {
        std::cout << "Found achievement: " << it->second.name << '\n';
    }

    for (auto it = achievementsUpdateAck.repeatAchievements.begin(); it != achievementsUpdateAck.repeatAchievements.end(); it++)
    {
        std::cout << "Found repeating achievement: " << it->second.name << '\n';
    }
}

void onError(const Nakama::NError& error)
{
    std::cout << Nakama::toString(error.code) << ": " << error.message << '\n';
}

Hiro::AchievementsUpdateRequest request;
request.ids = {"achievement_1", "achievement_2"};
request.amount = 1;

hiroClient->achievementsUpdate(session, request, onAchievementsUpdate, onError);