Skip to main content

Display rewards within your game

Last updated on April 4, 2024

Overview

The AccelByte Gaming Services (AGS) reward service allows you to display rewards to the user in various ways. Displaying rewards within the game can provide players a clear goal to strive for. In this guide, you will learn how to display the rewards within the game.

Goals

  • Explain how to use AccelByte SDK to display available rewards based on configurations that are set.

Prerequisites

  • Access to the AGS Admin Portal.
  • AccelByte Unreal or Unity SDK, including the permissions:
    • Client ID
    • Client Secret
  • Access to AccelByte Platform service API documentation.
  • Reward configuration should exist in the related namespace.

Displaying rewards

After you have your reward configurations are set up, you can choose to display a single reward or a list of rewards in your game UI.

Display a single reward

You can retrieve the reward information that you want to display using Reward ID or Code. This is suitable if you only want to display specific reward information to the players. Please follow the function below to retrieve the reward information:

Retrieve by reward ID

Unreal Engine
FString RewardId = TEXT("YourRewardId");

AccelByte::FRegistry::Reward.GetRewardByRewardId(RewardId,
THandler<FAccelByteModelsRewardInfo>::CreateLambda([&](const FAccelByteModelsRewardInfo& Result)
{
// Do something when successful
}),
FErrorHandler::CreateLambda([](int32 ErrorCode, FString ErrorMessage)
{
// Do something when failed
})
);

Retrieve by reward code

Unreal Engine
FString RewardCode = TEXT("YourRewardCode");

AccelByte::FRegistry::Reward.GetRewardByRewardCode(RewardId,
THandler<FAccelByteModelsRewardInfo>::CreateLambda([&](const FAccelByteModelsRewardInfo& Result)
{
// Do something when successful
}),
FErrorHandler::CreateLambda([](int32 ErrorCode, FString ErrorMessage)
{
// Do something when failed
})
);

Display list of rewards

You can also get a list of available rewards in your namespace and filter it. This is suitable if you want to let your players know all of the available rewards within the game. Please follow the function below to retrieve the list of rewards:

Unreal Engine
FString EventTopic = TEXT("YourEventTopic");
int32 Offset = 0;
int32 Limit = 1000;
EAccelByteRewardListSortBy SortBy = EAccelByteRewardListSortBy::REWARDCODE_ASC;

AccelByte::FRegistry::Reward.QueryRewards(EventTopic, Offset, Limit, SortBy,
THandler<FAccelByteModelsQueryReward>::CreateLambda([&](const FAccelByteModelsQueryReward& Result)
{
// Do something when successful
}),
FErrorHandler::CreateLambda([](int32 ErrorCode, FString ErrorMessage)
{
// Do something when failed
})
);