Store player attributes in public records
Overview
The Cloud Save service enables you to store your players' data publicly. Storing publicly means you're allowing other players to read specific player's data. You can retrieve, modify, and delete any data that you store, which is in JSON format.
The data stored is usually non-sensitive data which is fine to be displayed publicly to other players, and there are no privacy rules for the data. Storing, for example:
- Player profile data such as player status, player info, job, role, tier, level, etc.
- Player customized weapon loadout, etc.
In this guide, you will learn how to utilize a player record to store your player data publicly, display it within the game client, and modify it according to your game use case.
Goals
The goals of this section are to:
- Provide an understanding and overview of public player records
- Provide an understanding on how to store player data in public player records
- Provide an understanding on how to display public player records
- Provide an understanding on how to modify public player records
- Provide an understanding on how to delete public player records
- Explain how to utilize public player records using the AccelByte SDK
Prerequisites
You will need access to:
- The Admin Portal
- The AGS Unreal, Unity, or Extend SDK, including the required permission:
- Client ID
- Client Secret
- The AGS Cloud Save API documentation
Storing User Data in a Public Player Record
Storing user data is important for a game, because this can make the game experience more enjoyable as players don't need to start over every time they play.
There are two methods to store Cloud Save public player records that you can choose, based on your game use case:
- Store via the game client: the data stored can be modified from both game client or game server.
- Store via the game server: the data stored via a game server can only be modified by a game server.
The only difference between the two methods above is the write permission that can be assigned for the record. For more information about record write permission, check this section.
Store user data in public player records via a game client
This is suitable for storing data such as player information, for example player weapon loadouts.
This example shows you how to store user data inside the playerInformation key, via the game client.
If the key already exists, the new data will be appended to the existing record.
- Unreal Engine
- Unity
- Go Extend SDK
- Python Extend SDK
- Java Extend SDK
- C# Extend SDK
FApiClientPtr ApiClient = FMultiRegistry::GetApiClient();
FString Key = "playerInformation";
TSharedPtr<FJsonObject> RecordRequest = MakeShareable(new FJsonObject);
RecordRequest->SetStringField("FirstName", "John");
ApiClient->CloudSave.SaveUserRecord(Key
, *RecordRequest
, true
, FVoidHandler::CreateLambda([]()
{
// Do something if SaveUserRecord is successful
})
, FErrorHandler::CreateLambda([](int32 ErrorCode, FString ErrorMessage)
{
// Do something if SaveUserRecord has an error
}));
CloudSave cloudSave = AccelByteSDK.GetClientRegistry().GetApi().GetCloudSave();
bool isPublic = true;
string key = "playerInformation";
Dictionary<string, object> recordRequest = new Dictionary<string, object>
{
{"FirstName", "John" }
};
cloudSave.SaveUserRecord(key, recordRequest, 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}");
return;
}
// Do something if SaveUserRecord is successful
}
, isPublic);
publicPlayerRecordService := &cloudsave.PublicPlayerRecordService{
Client: factory.NewCloudsaveClient(&repository.ConfigRepositoryImpl{}),
TokenRepository: &repository.TokenRepositoryImpl{},
}
key := "playerInformation"
body := map[string]interface{}{"FirstName": "John"}
namespace := "mygame"
userId := "myuserid"
input := &public_player_record.PostPlayerPublicRecordHandlerV1Params{
Body: body,
Key: key,
Namespace: namespace,
UserID: userId,
}
result, err := publicPlayerRecordService.PostPlayerPublicRecordHandlerV1Short(input)
import accelbyte_py_sdk.api.cloudsave as cloudsave_service
import accelbyte_py_sdk.api.cloudsave.models as cloudsave_models
result, error = cloudsave_service.post_player_record_handler_v1(
body=cloudsave_models.ModelsPlayerRecordRequest.create(
{
"FirstName": "John",
"__META": {
"is_public": True,
}
}
),
key="playerInformation",
)
if error:
exit(error)
@Builder
public class MyRecordRequest extends ModelsPlayerRecordRequest {
@JsonProperty("firstName")
private String firstName;
}
...
final PublicPlayerRecord publicPlayerRecordWrapper = new PublicPlayerRecord(sdk);
String key = "playerInformation";
String userId = "<user-id>";
String firstName = "John";
ModelsPlayerRecordResponse response;
try {
var record = MyRecordRequest.builder().firstName(firstName).build();
response = publicPlayerRecordWrapper.postPlayerPublicRecordHandlerV1(PostPlayerPublicRecordHandlerV1.builder()
.namespace("<namespace>")
.userId(userId)
.key(key)
.body(record)
.build());
} catch (Exception e) {
// Do something when failed
return;
}
if (response == null) {
// Null response from server
} else {
// Do something with response when success
}
public class MyRecordRequest : ModelsPlayerRecordRequest
{
[JsonPropertyName("firstName")]
public string FirstName { get; set; } = "";
}
string key = "playerInformation";
string userId = "<user-id>";
var record = new MyRecordRequest()
{
FirstName = "John"
};
var response = sdk.Cloudsave.PublicPlayerRecord.PostPlayerPublicRecordHandlerV1Op
.Execute(record, key, sdk.Namespace, userId);
if (response != null)
{
//do something with response when success
}
Store user data in public player records via a game server
This is suitable for storing data such as player rank or tier, that is updated by specific game logic, and not triggered manually by the player.
This example below shows you how to store user data inside the playerTier key, via the game server.
- Unreal Engine
- Unity
- Go Extend SDK
- Python Extend SDK
- Java Extend SDK
- C# Extend SDK
FServerApiClientPtr ApiServer = FMultiRegistry::GetServerApiClient();
FString Key = "playerTier";
FString UserId = "Player User Id";
ESetByMetadataRecord SetBy = ESetByMetadataRecord::SERVER;
TSharedPtr<FJsonObject> RecordRequest = MakeShareable(new FJsonObject);
RecordRequest->SetStringField("Rank", "Legend");
ApiServer->ServerCloudSave.SaveUserRecord(Key
, UserId
, SetBy
, true
, *RecordRequest
, FVoidHandler::CreateLambda([]()
{
// Do something if SaveUserRecord is successful
})
, FErrorHandler::CreateLambda([](int32 ErrorCode, FString ErrorMessage)
{
// Do something if SaveUserRecord has an error
}));
ServerCloudSave serverCloudSave = AccelByteSDK.GetServerRegistry().GetApi().GetCloudSave();
string key = "playerTier";
string userId = "Player User Id";
RecordSetBy setBy = RecordSetBy.SERVER;
bool isPublic = true;
Dictionary<string, object> recordRequest = new Dictionary<string, object>
{
{"Rank", "Legend" }
};
serverCloudSave.SaveUserRecord(userId, key, recordRequest, setBy, isPublic, 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}");
return;
}
// Do something if SaveUserRecord is successful
});
publicPlayerRecordService := &cloudsave.PublicPlayerRecordService{
Client: factory.NewCloudsaveClient(&repository.ConfigRepositoryImpl{}),
TokenRepository: &repository.TokenRepositoryImpl{},
}
key := "playerTier"
body := map[string]interface{}{
"Rank": "Legend",
"__META": map[string]interface{}{
"set_by":"SERVER",
"is_public": true,
},
}
namespace := "mygame"
userId := "myuserid"
input := &public_player_record.PostPlayerPublicRecordHandlerV1Params{
Body: body,
Key: key,
Namespace: namespace,
UserID: userId,
}
result, err := publicPlayerRecordService.PostPlayerPublicRecordHandlerV1Short(input)
import accelbyte_py_sdk.api.cloudsave as cloudsave_service
import accelbyte_py_sdk.api.cloudsave.models as cloudsave_models
result, error = cloudsave_service.admin_post_player_record_handler_v1(
body=cloudsave_models.ModelsPlayerRecordRequest.create(
{
"Rank": "Legend",
"__META": {
"set_by": "SERVER",
"is_public": True,
}
}
),
key="playerTier",
user_id="********************************",
)
if error:
exit(error)
@Builder
public class MyRecordRequestWithMeta extends ModelsPlayerRecordRequest {
@Builder
public class Meta
{
@JsonProperty("set_by")
public String setBy;
@JsonProperty("is_public")
public boolean isPublic;
}
@JsonProperty("__META")
public Meta RecordMeta;
@JsonProperty("firstName")
public String firstName;
}
...
AdminPlayerRecord adminPlayerRecordWrapper = new AdminPlayerRecord(sdk);
String key = "playerInformation";
String userId = "<user-id>";
String firstName = "John";
ModelsPlayerRecordResponse response;
try {
var serverRecord = MyRecordRequestWithMeta
.builder()
.firstName(firstName)
.RecordMeta(MyRecordRequestWithMeta.Meta.builder()
.setBy("SERVER")
.isPublic(true)
.build())
.build();
response = adminPlayerRecordWrapper.adminPostPlayerPublicRecordHandlerV1(AdminPostPlayerPublicRecordHandlerV1.builder()
.namespace("<namespace>")
.userId(userId)
.key(key)
.body(serverRecord)
.build());
} catch (Exception e) {
// Do something when failed
return;
}
if (response == null) {
// Null response from server
} else {
// Do something with response when success
}
public class MyRecordRequestWithMeta : ModelsPlayerRecordRequest
{
public class Meta
{
[JsonPropertyName("set_by")]
public string SetBy { get; set; } = "";
[JsonPropertyName("is_public")]
public bool IsPublic { get; set; } = false;
}
[JsonPropertyName("__META")]
public Meta RecordMeta { get; set; } = new Meta();
[JsonPropertyName("firstName")]
public string FirstName { get; set; } = "";
}
string key = "playerInformation";
string userId = "<user-id>";
var serverRecord = new MyRecordRequestWithMeta()
{
RecordMeta = new MyRecordRequestWithMeta.Meta()
{
SetBy = "SERVER",
IsPublic = true
},
FirstName = "John"
};
var response = sdk.Cloudsave.AdminPlayerRecord.AdminPostPlayerPublicRecordHandlerV1Op
.Execute(serverRecord, key, sdk.Namespace, userId);
if (response != null)
{
//do something with response when success
}
Display public player record data
You can retrieve and display the records you store accordingly based on your game use case. There are two general approaches to displaying player records, based on the record owner:
- Own public player records. For example: a my player info page.
- Other user public player records. For example: other users' player info page.
Display your own public player record
This example below shows you how to retrieve user data inside the playerInfo key.
- Unreal Engine
- Unity
- Go Extend SDK
- Python Extend SDK
- Java Extend SDK
- C# Extend SDK
FApiClientPtr ApiClient = FMultiRegistry::GetApiClient();
FString Key = "playerInfo";
ApiClient->CloudSave.GetUserRecord(Key
, THandler<FAccelByteModelsUserRecord>::CreateLambda([](FAccelByteModelsUserRecord Result)
{
// Do something if GetUserRecord is successful
})
, FErrorHandler::CreateLambda([](int32 ErrorCode, FString ErrorMessage)
{
// Do something if GetUserRecord has an error
}));
CloudSave cloudSave = AccelByteSDK.GetClientRegistry().GetApi().GetCloudSave();
string key = "playerInfo";
cloudSave.GetUserRecord(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}");
return;
}
// Do something if GetUserRecord is successful
});
publicPlayerRecordService := &cloudsave.PublicPlayerRecordService{
Client: factory.NewCloudsaveClient(&repository.ConfigRepositoryImpl{}),
TokenRepository: &repository.TokenRepositoryImpl{},
}
key := "playerInfo"
namespace := "mygame"
userId := "myuserid"
input := &public_player_record.GetPlayerPublicRecordHandlerV1Params{
Key: key,
Namespace: namespace,
UserID: userId,
}
result, err := publicPlayerRecordService.GetPlayerPublicRecordHandlerV1Short(input)
import accelbyte_py_sdk.api.cloudsave as cloudsave_service
import accelbyte_py_sdk.api.cloudsave.models as cloudsave_models
result, error = cloudsave_service.get_player_record_handler_v1(
key="playerInfo",
user_id="********************************",
)
if error:
exit(error)
PublicPlayerRecord publicPlayerRecordWrapper = new PublicPlayerRecord(sdk);
String key = "playerInformation";
String userId = "<user-id>";
ModelsPlayerRecordResponse response;
try {
response = publicPlayerRecordWrapper.getPlayerPublicRecordHandlerV1(GetPlayerPublicRecordHandlerV1.builder()
.namespace("<namespace>")
.userId(userId)
.key(key)
.build());
} catch (Exception e) {
// Do something when failed
return;
}
if (response == null) {
// Null response from server
} else {
// Do something with the data
}
string key = "playerInformation";
string userId = "<user-id>";
var response = sdk.Cloudsave.PublicPlayerRecord.GetPlayerPublicRecordHandlerV1Op
.Execute(key, sdk.Namespace, userId);
if (response != null)
{
//do something with the data
}
Display other use public player records
A public user record can be retrieved by another user. This example below shows you how to retrieve other user player records data inside the playerInfo key.
- Unreal Engine
- Unity
- Go Extend SDK
- Python Extend SDK
- Java Extend SDK
- C# Extend SDK
FApiClientPtr ApiClient = FMultiRegistry::GetApiClient();
FString Key = "playerInfo";
FString UserId = "Player User Id";
ApiClient->CloudSave.GetPublicUserRecord(Key
, UserId
, THandler<FAccelByteModelsUserRecord>::CreateLambda([](FAccelByteModelsUserRecord Result)
{
// Do something if GetPublicUserRecord is successful
})
, FErrorHandler::CreateLambda([](int32 ErrorCode, FString ErrorMessage)
{
// Do something if GetPublicUserRecord has an error
}));
CloudSave cloudSave = AccelByteSDK.GetClientRegistry().GetApi().GetCloudSave();
string key = "playerInfo";
string userId = "Player User Id";
cloudSave.GetPublicUserRecord(key, userId, result =>
{
if (result.IsError)
{
// Do something if GetPublicUserRecord has an error
Debug.Log($"Error GetPublicUserRecord, Error Code: {result.Error.Code} Error Message: {result.Error.Message}");
return;
}
// Do something if GetPublicUserRecord is successful
});
publicPlayerRecordService := &cloudsave.PublicPlayerRecordService{
Client: factory.NewCloudsaveClient(&repository.ConfigRepositoryImpl{}),
TokenRepository: &repository.TokenRepositoryImpl{},
}
key := "playerInfo"
namespace := "mygame"
userId := "myuserid"
input := &public_player_record.GetPlayerPublicRecordHandlerV1Params{
Key: key,
Namespace: namespace,
UserID: userId,
}
result, err := publicPlayerRecordService.GetPlayerPublicRecordHandlerV1Short(input)
import accelbyte_py_sdk.api.cloudsave as cloudsave_service
import accelbyte_py_sdk.api.cloudsave.models as cloudsave_models
result, error = cloudsave_service.get_player_record_handler_v1(
key="playerInfo",
user_id="********************************",
)
if error:
exit(error)
PublicPlayerRecord publicPlayerRecordWrapper = new PublicPlayerRecord(sdk);
String key = "playerInformation";
String userId = "<user-id>";
ModelsPlayerRecordResponse response;
try {
response = publicPlayerRecordWrapper.getPlayerPublicRecordHandlerV1(GetPlayerPublicRecordHandlerV1.builder()
.namespace("<namespace>")
.userId(userId)
.key(key)
.build());
} catch (Exception e) {
// Do something when failed
return;
}
if (response == null) {
// Null response from server
} else {
// Do something with the data
}
string key = "playerInformation";
string userId = "<user-id>";
var response = sdk.Cloudsave.PublicPlayerRecord.GetPlayerPublicRecordHandlerV1Op
.Execute(key, sdk.Namespace, userId);
if (response != null)
{
//do something with the data
}
Modify public player record data
Player record data can be modified based on your game use case. There are two methods to modify Cloud Save public player records that you can choose based on your use case:
- Modify via a game client. This is suitable if you want to allow your player to modify their player records. For example: user update player information.
- Modify via a game server. This is suitable if you only want the game server to be able to modify player records. For example: a game server assigns a player a new rank or tier.
Modify public player records via a game client
There are two methods that you can use to modify the public player records:
- Replace: is suitable if you want to replace the entire data with new content. If the record does not exist, it will be created based on the new data, and if the record already exists, it will replace all of it.
- Append: is suitable if you only want to add new keys and values to player records. This process is lighter when compared to Replace.
Replace a user's public player record
The example below shows you how to replace user data inside the playerInfo key.
- Unreal Engine
- Unity
- Go Extend SDK
- Python Extend SDK
- Java Extend SDK
- C# Extend SDK
FApiClientPtr ApiClient = FMultiRegistry::GetApiClient();
FString Key = "playerInfo";
TSharedPtr<FJsonObject> RecordRequest = MakeShareable(new FJsonObject);
RecordRequest->SetStringField("FirstName", "Doe");
ApiClient->CloudSave.ReplaceUserRecord(Key
, true
, *RecordRequest
, FVoidHandler::CreateLambda([]()
{
// Do something if ReplaceUserRecord is successful
})
, FErrorHandler::CreateLambda([](int32 ErrorCode, FString ErrorMessage)
{
// Do something if ReplaceUserRecord has an error
}));
CloudSave cloudSave = AccelByteSDK.GetClientRegistry().GetApi().GetCloudSave();
string key = "playerInfo";
bool isPublic = true;
Dictionary<string, object> recordRequest = new Dictionary<string, object>
{
{"FirstName", "Doe" }
};
cloudSave.ReplaceUserRecord(key, isPublic, recordRequest, 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}");
return;
}
// Do something if ReplaceUserRecord is successful
});
publicPlayerRecordService := &cloudsave.PublicPlayerRecordService{
Client: factory.NewCloudsaveClient(&repository.ConfigRepositoryImpl{}),
TokenRepository: &repository.TokenRepositoryImpl{},
}
key := "playerInfo"
body := map[string]interface{}{"FirstName": "Doe"}
namespace := "mygame"
userId := "myuserid"
input := &public_player_record.PutPlayerPublicRecordHandlerV1Params{
Body: body,
Key: key,
Namespace: namespace,
UserID: userId,
}
result, err := publicPlayerRecordService.PutPlayerPublicRecordHandlerV1Short(input)
import accelbyte_py_sdk.api.cloudsave as cloudsave_service
import accelbyte_py_sdk.api.cloudsave.models as cloudsave_models
result, error = cloudsave_service.put_player_record_handler_v1(
body=cloudsave_models.ModelsPlayerRecordRequest.create(
{
"FirstName": "Doe",
"__META": {
"is_public": True,
}
}
),
key="playerInfo",
user_id="********************************",
)
if error:
exit(error)
final PublicPlayerRecord publicPlayerRecordWrapper = new PublicPlayerRecord(sdk);
String key = "playerInformation";
String userId = "<user-id>";
String firstName = "Jack";
ModelsPlayerRecordResponse response;
try {
var record = MyRecordRequest.builder().firstName(firstName).build();
response = publicPlayerRecordWrapper.putPlayerPublicRecordHandlerV1(PutPlayerPublicRecordHandlerV1.builder()
.namespace("<namespace>")
.userId(userId)
.key(key)
.body(record)
.build());
} catch (Exception e) {
// Do something when failed
return;
}
if (response == null) {
// Null response from server
} else {
// Do something with response when success
}
string key = "playerInformation";
string userId = "<user-id>";
var record = new MyRecordRequest()
{
FirstName = "Jack"
};
var response = sdk.Cloudsave.PublicPlayerRecord.PutPlayerPublicRecordHandlerV1Op
.Execute(record, key, sdk.Namespace, userId);
if (response != null)
{
//do something with response when success
}
Append a user's public player record
This example below shows you how to append user data inside the playerInfo key.
- Unreal Engine
- Unity
- Go Extend SDK
- Python Extend SDK
- Java Extend SDK
- C# Extend SDK
FApiClientPtr ApiClient = FMultiRegistry::GetApiClient();
FString Key = "playerInfo";
TSharedPtr<FJsonObject> RecordRequest = MakeShareable(new FJsonObject);
RecordRequest->SetStringField("LastName", "Doe");
ApiClient->CloudSave.SaveUserRecord(Key
, *RecordRequest
, true
, FVoidHandler::CreateLambda([]()
{
// Do something if SaveUserRecord is successful
})
, FErrorHandler::CreateLambda([](int32 ErrorCode, FString ErrorMessage)
{
// Do something if SaveUserRecord has an error
}));
CloudSave cloudSave = AccelByteSDK.GetClientRegistry().GetApi().GetCloudSave();
bool isPublic = true;
string key = " playerInfo";
Dictionary<string, object> recordRequest = new Dictionary<string, object>
{
{"LastName", "Doe" }
};
cloudSave.SaveUserRecord(key, recordRequest, 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}");
return;
}
// Do something if SaveUserRecord is successful
}
, isPublic);
publicPlayerRecordService := &cloudsave.PublicPlayerRecordService{
Client: factory.NewCloudsaveClient(&repository.ConfigRepositoryImpl{}),
TokenRepository: &repository.TokenRepositoryImpl{},
}
key := "playerInformation"
body := map[string]interface{}{
"LastName": "Doe",
}
namespace := "mygame"
userId := "myuserid"
input := &public_player_record.PostPlayerPublicRecordHandlerV1Params{
Body: body,
Key: key,
Namespace: namespace,
UserID: userId,
}
result, err := publicPlayerRecordService.PostPlayerPublicRecordHandlerV1Short(input)
import accelbyte_py_sdk.api.cloudsave as cloudsave_service
import accelbyte_py_sdk.api.cloudsave.models as cloudsave_models
result, error = cloudsave_service.post_player_record_handler_v1(
body=cloudsave_models.ModelsPlayerRecordRequest.create(
{
"LastName": "Doe",
"__META": {
"is_public": True,
}
}
),
key="playerInformation",
)
if error:
exit(error)
@Builder
public class MyRecordRequest extends ModelsPlayerRecordRequest {
@JsonProperty("firstName")
private String firstName;
@JsonProperty("lastName")
private String lastName;
}
...
PublicPlayerRecord publicPlayerRecordWrapper = new PublicPlayerRecord(sdk);
String key = "playerInformation";
String userId = "<user-id>";
String lastName = "Doe";
ModelsPlayerRecordResponse response;
try {
var record = MyRecordRequest.builder().lastName(lastName).build();
response = publicPlayerRecordWrapper.postPlayerPublicRecordHandlerV1(PostPlayerPublicRecordHandlerV1.builder()
.namespace("<namespace>")
.userId(userId)
.key(key)
.body(record)
.build());
} catch (Exception e) {
// Do something when failed
return;
}
if (response == null) {
// Null response from server
} else {
// Do something with response when success
}
public class MyRecordRequest : ModelsPlayerRecordRequest
{
[JsonPropertyName("firstName")]
public string FirstName { get; set; } = "";
[JsonPropertyName("lastName")]
public string LastName { get; set; } = "";
}
string key = "playerInformation";
string userId = "<user-id>";
var record = new MyRecordRequest()
{
LastName = "Doe"
};
var response = sdk.Cloudsave.PublicPlayerRecord.PostPlayerPublicRecordHandlerV1Op
.Execute(record, key, sdk.Namespace, userId);
if (response != null)
{
//do something with response when success
}
Modify public player records via a game server
A Game server has the most permissions for modifying public player records data. For more information about the record write permission check this section.
The example below shows you how to modify player record data inside the playerTier key via the game server.
- Unreal Engine
- Unity
- Go Extend SDK
- Python Extend SDK
- Java Extend SDK
- C# Extend SDK
FServerApiClientPtr ApiServer = FMultiRegistry::GetServerApiClient();
FString Key = "playerTier";
FString UserId = "Player User Id";
ESetByMetadataRecord SetBy = ESetByMetadataRecord::SERVER;
TSharedPtr<FJsonObject> RecordRequest = MakeShareable(new FJsonObject);
RecordRequest->SetStringField("Rank", "Diamond");
ApiServer->ServerCloudSave.ReplaceUserRecord(Key
, SetBy
, true
, UserId
, *RecordRequest
, FVoidHandler::CreateLambda([]()
{
// Do something if ReplaceUserRecord is successful
})
, FErrorHandler::CreateLambda([](int32 ErrorCode, FString ErrorMessage)
{
// Do something if ReplaceUserRecord has an error
}));
ServerCloudSave serverCloudSave = AccelByteSDK.GetServerRegistry().GetApi().GetCloudSave();
bool isPublic = true;
string key = "playerTier";
string userId = "Player User Id";
RecordSetBy setBy = RecordSetBy.SERVER;
Dictionary<string, object> recordRequest = new Dictionary<string, object>
{
{"Rank", "Diamond"}
};
serverCloudSave.ReplaceUserRecord(userId, key, recordRequest, setBy, isPublic, 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}");
return;
}
// Do something if ReplaceUserRecord is successful
});
adminPlayerRecordService := &cloudsave.AdminPlayerRecordService{
Client: factory.NewCloudsaveClient(&repository.ConfigRepositoryImpl{}),
TokenRepository: &repository.TokenRepositoryImpl{},
}
key := "playerTier"
body := map[string]interface{}{
"Rank": "Diamond",
"__META": map[string]interface{}{
"set_by":"SERVER",
"is_public": true,
},
}
namespace := "mygame"
userId := "myuserid"
input := &admin_player_record.AdminPutPlayerRecordHandlerV1Params{
Body: body,
Key: key,
Namespace: namespace,
UserID: userId,
}
result, err := adminPlayerRecordService.AdminPutPlayerRecordHandlerV1Short(input)
import accelbyte_py_sdk.api.cloudsave as cloudsave_service
import accelbyte_py_sdk.api.cloudsave.models as cloudsave_models
result, error = cloudsave_service.admin_put_player_record_handler_v1(
body=cloudsave_models.ModelsPlayerRecordRequest.create(
{
"Rank": "Diamond",
"__META": {
"set_by": "SERVER",
"is_public": True,
}
}
),
key="playerTier",
user_id="********************************",
)
if error:
exit(error)
AdminPlayerRecord adminPlayerRecordWrapper = new AdminPlayerRecord(sdk);
String key = "playerInformation";
String userId = "<user-id>";
String firstName = "Jack";
ModelsPlayerRecordResponse response;
try {
var serverRecord = MyRecordRequestWithMeta
.builder()
.firstName(firstName)
.RecordMeta(MyRecordRequestWithMeta.Meta.builder()
.setBy("SERVER")
.isPublic(true)
.build())
.build();
response = adminPlayerRecordWrapper.adminPutPlayerRecordHandlerV1(AdminPutPlayerRecordHandlerV1.builder()
.namespace("<namespace>")
.userId(userId)
.key(key)
.body(serverRecord)
.build());
} catch (Exception e) {
// Do something when failed
return;
}
if (response == null) {
// Null response from server
} else {
// Do something with response when success
}
string key = "playerInformation";
string userId = "<user-id>";
var serverRecord = new MyRecordRequestWithMeta()
{
RecordMeta = new MyRecordRequestWithMeta.Meta()
{
SetBy = "SERVER",
IsPublic = true
},
FirstName = "Jack"
};
var response = sdk.Cloudsave.AdminPlayerRecord.AdminPutPlayerRecordHandlerV1Op
.Execute(serverRecord, key, sdk.Namespace, userId);
if (response != null)
{
//do something with response when success
}
Delete public player records for a specific user
You can also delete public player record data. Deleting player record data can be done from a game client or game server.
Delete a user's public player record via a game client
This example below shows you how to delete user record data with the playerInfo key, via a game client.
- Unreal Engine
- Unity
- Go Extend SDK
- Python Extend SDK
- Java Extend SDK
- C# Extend SDK
FApiClientPtr ApiClient = FMultiRegistry::GetApiClient();
FString Key = "playerInfo";
ApiClient->CloudSave.DeleteUserRecord(Key
, FVoidHandler::CreateLambda([]()
{
// Do something if DeleteUserRecord is successful
})
, FErrorHandler::CreateLambda([](int32 ErrorCode, FString ErrorMessage)
{
// Do something if DeleteUserRecord has an error
}));
CloudSave cloudSave = AccelByteSDK.GetClientRegistry().GetApi().GetCloudSave();
string key = "playerInfo";
cloudSave.DeleteUserRecord(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}");
return;
}
// Do something if DeleteUserRecord is successful
});
publicPlayerRecordService := &cloudsave.PublicPlayerRecordService{
Client: factory.NewCloudsaveClient(&repository.ConfigRepositoryImpl{}),
TokenRepository: &repository.TokenRepositoryImpl{},
}
key := "playerInformation"
namespace := "mygame"
input := &public_player_record.PublicDeletePlayerPublicRecordHandlerV1Params{
Key: key,
Namespace: namespace,
}
err := publicPlayerRecordService.PublicDeletePlayerPublicRecordHandlerV1Short(input)
import accelbyte_py_sdk.api.cloudsave as cloudsave_service
import accelbyte_py_sdk.api.cloudsave.models as cloudsave_models
result, error = cloudsave_service.delete_player_record_handler_v1(
key="playerInfo",
user_id="********************************",
)
if error:
exit(error)
final PublicPlayerRecord publicPlayerRecordWrapper = new PublicPlayerRecord(sdk);
String key = "playerInformation";
try {
publicPlayerRecordWrapper.publicDeletePlayerPublicRecordHandlerV1(PublicDeletePlayerPublicRecordHandlerV1.builder()
.namespace("<namespace>")
.key(key)
.build());
} catch (Exception e) {
// Do something when failed
return;
}
string key = "playerInformation";
sdk.Cloudsave.PublicPlayerRecord.PublicDeletePlayerPublicRecordHandlerV1Op
.Execute(key, sdk.Namespace);
Delete a user's public player record via a game server
This example below shows you how to delete user record data with the playerTier key, via a game server.
- Unreal Engine
- Unity
- Go Extend SDK
- Python Extend SDK
- Java Extend SDK
- C# Extend SDK
FServerApiClientPtr ApiServer = FMultiRegistry::GetServerApiClient();
FString Key = "playerTier";
FString UserId = "Player User Id";
ApiServer->ServerCloudSave.DeleteUserRecord(Key
, UserId
, true
, FVoidHandler::CreateLambda([]()
{
// Do something if DeleteUserRecord is successful
})
, FErrorHandler::CreateLambda([](int32 ErrorCode, FString ErrorMessage)
{
// Do something if DeleteUserRecord has an error
}));
ServerCloudSave serverCloudSave = AccelByteSDK.GetServerRegistry().GetApi().GetCloudSave();
string key = "playerTier";
string userId = "Player User Id";
serverCloudSave.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}");
return;
}
// Do something if DeleteUserRecord is successful
});
adminPlayerRecordService := &cloudsave.AdminPlayerRecordService{
Client: factory.NewCloudsaveClient(&repository.ConfigRepositoryImpl{}),
TokenRepository: &repository.TokenRepositoryImpl{},
}
key := "playerInformation"
namespace := "mygame"
userId := "myuserid"
input := &admin_player_record.AdminDeletePlayerPublicRecordHandlerV1Params{
Key: key,
Namespace: namespace,
UserID: userId,
}
err := adminPlayerRecordService.AdminDeletePlayerPublicRecordHandlerV1Short(input)
import accelbyte_py_sdk.api.cloudsave as cloudsave_service
import accelbyte_py_sdk.api.cloudsave.models as cloudsave_models
result, error = cloudsave_service.admin_delete_player_record_handler_v1(
key="playerTier",
user_id="********************************",
)
if error:
exit(error)
AdminPlayerRecord adminPlayerRecordWrapper = new AdminPlayerRecord(sdk);
String key = "playerInformation";
String userId = "<user-id>";
try {
adminPlayerRecordWrapper.adminDeletePlayerPublicRecordHandlerV1(AdminDeletePlayerPublicRecordHandlerV1.builder()
.namespace("<namespace>")
.userId(userId)
.key(key)
.build());
} catch (Exception e) {
// Do something when failed
return;
}
string key = "playerInformation";
string userId = "<user-id>";
sdk.Cloudsave.AdminPlayerRecord.AdminDeletePlayerPublicRecordHandlerV1Op
.Execute(key, sdk.Namespace, userId);