Store restricted player and game data in admin records
Goals
In this guide, you will learn:
- How to access admin records in the AccelByte Gaming Services (AGS) Admin Portal.
- How to create, modify, retrieve, and delete admin records.
Prerequisites
You will need access to:
- The AGS Admin Portal
- The AccelByte Cloud Save API documentation
Manage admin records in the Admin Portal
Access the Admin Records page
In your namespace on the AGS Admin Portal, go to the Game Management section.
Open the Cloud Save menu and select Admin Records.
On the Admin Record page, you will see two tabs: Game Records and Player Records. Open a tab to view a list of records it contains.
Create a new admin record
To create a new admin record to store player or game data, follow these steps:
On the Admin Record page, select the Game Records or the Player Records tab, based on the type of record you want to create. Then, click the Create button.
- Admin Game Records: The data will not be associated with a specific user ID and can be used to store game wide data but only an admin/game server can access it.
- Admin Player Records: The data will be associated with a specific user ID and can be used to store specific user data but only the admin/game server can access it.
Fill in the required fields on the form.
Game Records
In the User ID box, add the user ID of the user that will be associated with the record.
In the Key box, add the Game Record key. This is the identifier of the record.
In the JSON Configuration box, add the data you want to store in JSON format.
Player Records
In the User ID box, add the user ID of the user that will be associated with the record.
In the Key box, add the Player Record key. This is the identifier of the record.
In the JSON Configuration box, add the data you want to store in JSON format.
After filling in the information, click Add to create the new record. The new record will be added to the list.
Modify admin records
The AGS Admin Portal allows you to modify admin records if you want to take manual action with the data, such as fixing data, auditing, etc.
To modify an admin record, follow these steps:
In the Game Management sercton, go to the Cloud Save menu and select Admin Records.
On the Admin Record page, go to the records tab that contains the record you want to modify.
a. For game records you can simply choose the record you want to modify by clicking View in the Action menu.
b. For player records you need to search the records by User ID first and choose the record you want to modify by clicking View in the Action menu.
In the Record Detail page, go to the JSON Configuration section and click Edit.
Update the record as needed.
Click Save to finish.
Delete admin records
THe AGS Admin Portal allows you to delete admin records if you want to delete records as necessary.
To delete an admin record, follow these steps:
In the Game Management section, go to the Cloud Save menu and select Admin Records.
On the Admin Record page, you will find 2 tabs Game and Player Records. Navigate to the desired tab, a. For game records you can simply choose the record you want to delete by clicking Delete in the Action menu.
b. For player records you need to search the records by User ID first and choose the record you want to delete by clicking Delete in the Action menu.
The Delete Record confirmation pop-up will appear. Click Delete to finish.
Manage admin records with the Server SDK
With the Server SDK, you can:
- Create new admin records to store player or game data
- Retrieve admin records
- Modify admin records
- Delete admin records
Create new admin records to store player or game data via Game Server
You can create admin records that are dynamically created after some actions are triggered from the Game Server. This function can be used to store additional match information, which is restricted for the player and can be used by the Game Server for the next match.
You can create a new record and store the data through the following methods:
Create admin game records
- Unreal Engine
- Unity
FServerApiClientPtr ServerApiClient = FMultiRegistry::GetServerApiClient();
FString Key = "SomeCloudSaveKey";
FJsonObject DataJson;
const FString gameId = FGuid::NewGuid().ToString();
DataJson.SetStringField("gameId", gameId);
DataJson.SetStringField("region", TEXT("ID"));
DataJson.SetStringField("language", TEXT("en"));
ServerApiClient->ServerCloudSave.SaveGameRecord(Key, DataJson, FVoidHandler::CreateLambda([]()
{
// Do something if SaveGameRecord has been successful
}), FErrorHandler::CreateLambda([](int32 ErrorCode, const FString& ErrorMessage)
{
// Do something if SaveGameRecord has an error
UE_LOG(LogTemp, Log, TEXT("Error SaveGameRecord, Error Code: %d Error Message: %s"), ErrorCode, *ErrorMessage);
}));
string key = "SomeCloudSaveKey";
string gameId = Guid.NewGuid().ToString();
Dictionary<string, object> dataJson = new Dictionary<string, object>
{
{"gameId", gameId }, {"region", "ID" }, {"language", "en" }
};
RecordSetBy setBy = RecordSetBy.SERVER;
Result callbackResult = null;
AccelByteServerPlugin.GetCloudSave().SaveGameRecord(key, dataJson, setBy, result =>
{
if (result.IsError)
{
// Do something if SaveGameRecord has an error
Debug.Log($"Error SaveGameRecord, Error Code: {result.Error.Code} Error Message: {result.Error.Message}");
}
else
{
callbackResult = result;
// Do something if SaveGameRecord has been successful
}
});
Create admin player records
- Unreal Engine
- Unity
FServerApiClientPtr ServerApiClient = FMultiRegistry::GetServerApiClient();
FString UserId = "SomeUserId";
FString Key = "SomeCloudSaveKey";
FJsonObject DataJson;
const FString gameId = FGuid::NewGuid().ToString();
DataJson.SetStringField("gameId", gameId);
DataJson.SetStringField("region", TEXT("ID"));
DataJson.SetStringField("language", TEXT("en"));
ServerApiClient->ServerCloudSave.SaveUserRecord(UserId, Key, DataJson, FVoidHandler::CreateLambda([]()
{
// Do something if SaveUserRecord has been successful
}), FErrorHandler::CreateLambda([](int32 ErrorCode, const FString& ErrorMessage)
{
// Do something if SaveUserRecord has an error
UE_LOG(LogTemp, Log, TEXT("Error SaveUserRecord, Error Code: %d Error Message: %s"), ErrorCode, *ErrorMessage);
}));
string userId = "SomeUserId";
string key = "SomeCloudSaveKey";
string gameId = Guid.NewGuid().ToString();
Dictionary<string, object> dataJson = new Dictionary<string, object>
{
{"gameId", gameId }, {"region", "ID" }, {"language", "en" }
};
Result callbackResult = null;
AccelByteServerPlugin.GetCloudSave().SaveUserRecord(userId, key, dataJson, result =>
{
if (result.IsError)
{
// Do something if SaveUserRecord has an error
Debug.Log($"Error SaveUserRecord, Error Code: {result.Error.Code} Error Message: {result.Error.Message}");
}
else
{
callbackResult = result;
// Do something if SaveUserRecord has been successful
}
});
Retrieve admin records from Game Server
You can retrieve admin records from the Game server through the following methods:
Retrieve a specific admin game record by key
Retrieve a specific admin game record by key
- Unreal Engine
- Unity
FServerApiClientPtr ServerApiClient = FMultiRegistry::GetServerApiClient();
FString Key = "SomeCloudSaveKey";
ServerApiClient->ServerCloudSave.GetGameRecord(Key, THandler<FAccelByteModelsGameRecord>::CreateLambda([](const FAccelByteModelsGameRecord& Response)
{
// Do something if GetGameRecord has been successful
}), FErrorHandler::CreateLambda([](int32 ErrorCode, const FString& ErrorMessage)
{
// Do something if GetGameRecord has an error
UE_LOG(LogTemp, Log, TEXT("Error GetGameRecord, Error Code: %d Error Message: %s"), ErrorCode, *ErrorMessage);
}));
string key = "SomeCloudSaveKey";
Result<GameRecord> callbackResult = null;
AccelByteServerPlugin.GetCloudSave().GetGameRecords(key, result =>
{
if (result.IsError)
{
// Do something if GetGameRecords has an error
Debug.Log($"Error GetGameRecords, Error Code: {result.Error.Code} Error Message: {result.Error.Message}");
}
else
{
callbackResult = result;
// Do something if GetGameRecords has been successful
}
});
Retrieve a specific admin player record for a specific user ID key
- Unreal Engine
- Unity
FServerApiClientPtr ServerApiClient = FMultiRegistry::GetServerApiClient();
FString Key = "SomeCloudSaveKey";
FString UserId = "SomeUserId";
ServerApiClient->ServerCloudSave.GetUserRecord(Key, UserId, THandler<FAccelByteModelsUserRecord>::CreateLambda([](const FAccelByteModelsUserRecord& Response)
{
// Do something if GetUserRecord has been successful
}), FErrorHandler::CreateLambda([](int32 ErrorCode, const FString& ErrorMessage)
{
// Do something if GetUserRecord has an error
UE_LOG(LogTemp, Log, TEXT("Error GetUserRecord, Error Code: %d Error Message: %s"), ErrorCode, *ErrorMessage);
}));
string userId = "SomeUserId";
string key = "SomeCloudSaveKey";
Result<UserRecord> callbackResult = null;
AccelByteServerPlugin.GetCloudSave().GetUserRecord(userId, key, result =>
{
if (result.IsError)
{
// Do something if GetUserRecord has an error
Debug.Log($"Error GetUserRecord, Error Code: {result.Error.Code} Error Message: {result.Error.Message}");
}
else
{
callbackResult = result;
// Do something if GetUserRecord has been successful
}
});
Modify admin records from the Game Server
To modify or update data within admin records from the Game Server, follow these steps:
Modify admin game records
- Unreal Engine
- Unity
FServerApiClientPtr ServerApiClient = FMultiRegistry::GetServerApiClient();
FString Key = "SomeCloudSaveKey";
FJsonObject DataJson;
const FString gameId = FGuid::NewGuid().ToString();
DataJson.SetStringField("gameId", gameId);
DataJson.SetStringField("region", TEXT("ES"));
DataJson.SetStringField("language", TEXT("es"));
ServerApiClient->ServerCloudSave.ReplaceGameRecord(Key, DataJson, FVoidHandler::CreateLambda([]()
{
// Do something if ReplaceGameRecord has been successful
}), FErrorHandler::CreateLambda([](int32 ErrorCode, const FString& ErrorMessage)
{
// Do something if ReplaceGameRecord has an error
UE_LOG(LogTemp, Log, TEXT("Error ReplaceGameRecord, Error Code: %d Error Message: %s"), ErrorCode, *ErrorMessage);
}));
string key = "SomeCloudSaveKey";
string gameId = Guid.NewGuid().ToString();
Dictionary<string, object> dataJson = new Dictionary<string, object>
{
{"gameId", gameId }, {"region", "ES" }, {"language", "es" }
};
RecordSetBy setBy = RecordSetBy.SERVER;
Result callbackResult = null;
AccelByteServerPlugin.GetCloudSave().ReplaceGameRecord(key, dataJson, setBy, result =>
{
if (result.IsError)
{
// Do something if ReplaceGameRecord has an error
Debug.Log($"Error ReplaceGameRecord, Error Code: {result.Error.Code} Error Message: {result.Error.Message}");
}
else
{
callbackResult = result;
// Do something if ReplaceGameRecord has been successful
}
});
Modify admin player records
- Unreal Engine
- Unity
FServerApiClientPtr ServerApiClient = FMultiRegistry::GetServerApiClient();
FString Key = "SomeCloudSaveKey";
FString UserId = "SomeUserId";
FJsonObject DataJson;
const FString gameId = FGuid::NewGuid().ToString();
DataJson.SetStringField("gameId", gameId);
DataJson.SetStringField("region", TEXT("ES"));
DataJson.SetStringField("language", TEXT("es"));
ServerApiClient->ServerCloudSave.ReplaceUserRecord(Key, UserId, DataJson, FVoidHandler::CreateLambda([]()
{
// Do something if ReplaceUserRecord has been successful
}), FErrorHandler::CreateLambda([](int32 ErrorCode, const FString& ErrorMessage)
{
// Do something if ReplaceUserRecord has an error
UE_LOG(LogTemp, Log, TEXT("Error ReplaceUserRecord, Error Code: %d Error Message: %s"), ErrorCode, *ErrorMessage);
}));
string userId = "SomeUserId";
string key = "SomeCloudSaveKey";
string gameId = Guid.NewGuid().ToString();
Dictionary<string, object> dataJson = new Dictionary<string, object>
{
{"gameId", gameId }, {"region", "ES" }, {"language", "es" }
};
Result callbackResult = null;
AccelByteServerPlugin.GetCloudSave().ReplaceUserRecord(userId, key, dataJson, result =>
{
if (result.IsError)
{
// Do something if ReplaceUserRecord has an error
Debug.Log($"Error ReplaceUserRecord, Error Code: {result.Error.Code} Error Message: {result.Error.Message}");
}
else
{
callbackResult = result;
// Do something if ReplaceUserRecord has been successful
}
});
Delete admin records from game server
To delete admin records from the Game Server, follow these steps:
Delete Admin Game Records
- Unreal Engine
- Unity
FServerApiClientPtr ServerApiClient = FMultiRegistry::GetServerApiClient();
FString Key = "SomeCloudSaveKey";
ServerApiClient->ServerCloudSave.DeleteGameRecord(Key, FVoidHandler::CreateLambda([]()
{
// Do something if DeleteGameRecord has been successful
}), FErrorHandler::CreateLambda([](int32 ErrorCode, const FString& ErrorMessage)
{
// Do something if DeleteGameRecord has an error
UE_LOG(LogTemp, Log, TEXT("Error DeleteGameRecord, Error Code: %d Error Message: %s"), ErrorCode, *ErrorMessage);
}));
string key = "SomeCloudSaveKey";
Result callbackResult = null;
AccelByteServerPlugin.GetCloudSave().DeleteGameRecord(key, result =>
{
if (result.IsError)
{
// Do something if DeleteGameRecord has an error
Debug.Log($"Error DeleteGameRecord, Error Code: {result.Error.Code} Error Message: {result.Error.Message}");
}
else
{
callbackResult = result;
// Do something if DeleteGameRecord has been successful
}
});
Delete admin player records
- Unreal Engine
- Unity
FServerApiClientPtr ServerApiClient = FMultiRegistry::GetServerApiClient();
FString Key = "SomeCloudSaveKey";
FString UserId = "SomeUserId";
bool bIsPublic = true;
ServerApiClient->ServerCloudSave.DeleteUserRecord(Key, UserId, bIsPublic, FVoidHandler::CreateLambda([]()
{
// Do something if DeleteUserRecord has been successful
}), FErrorHandler::CreateLambda([](int32 ErrorCode, const FString& ErrorMessage)
{
// Do something if DeleteUserRecord has an error
UE_LOG(LogTemp, Log, TEXT("Error DeleteUserRecord, Error Code: %d Error Message: %s"), ErrorCode, *ErrorMessage);
}));
string userId = "SomeUserId";
string key = "SomeCloudSaveKey";
Result callbackResult = null;
AccelByteServerPlugin.GetCloudSave().DeleteUserRecord(userId, key, result =>
{
if (result.IsError)
{
// Do something if DeleteUserRecord has an error
Debug.Log($"Error DeleteUserRecord, Error Code: {result.Error.Code} Error Message: {result.Error.Message}");
}
else
{
callbackResult = result;
// Do something if DeleteUserRecord has been successful
}
});