Appearance
Appearance
Deleted
and cannot be played. If the user connects again after deletion, a new player state will be created.When player requests Account Deletion, the account is not deleted immediately. Instead, the deletion is scheduled in the future, allowing the player to change their mind and cancel the deletion. As such, the game client needs to implement the following steps:
We walk through these steps below.
You need to add a button, for example under settings or player profile, that allows a player to request account deletion. You'll want to be careful to not make it too easy for a player to accidentally schedule themselves for deletion - make sure that they understand the consequences of what they are about to do, and make sure that they understand the timescales for deletion and the window for canceling before they trigger the action.
For a player to schedule their deletion, the client just needs to send a message to the server. This will schedule the account deletion with the Safety Delay of MetaplaySDK.Connection.ServerOptions.DeletionRequestSafetyDelay
:
public void ScheduleDeletion()
{
PlayerScheduleDeletionRequest request = new PlayerScheduleDeletionRequest();
MetaplaySDK.MessageDispatcher.SendMessage(request);
// When the server receives the message, it will schedule the deletion to
// happen on Now + MetaplaySDK.Connection.ServerOptions.DeletionRequestSafetyDelay.
}
📝 Example implementation
In the Idler example project, this is implemented on the Account page managed by AccountScreenScript.cs
.
We highly recommend providing some in-game feedback to the player. Since player deletion is a very destructive action, you need to make sure that your player is aware of when they have been scheduled for deletion. With the messages and status information that Metaplay provides out-of-the-box, this is a straightforward process.
Deletion status can easily be queried through the PlayerModel
via the DeletionStatus
and ScheduledForDeletionAt
properties:
void Update()
{
if (MetaplayClient.PlayerModel.DeletionStatus == PlayerDeletionStatus.None)
{
// Hide the indicator
IndicatorGameObject.enabled = false;
}
else
{
// Show the indicator and countdown towards the deletion. Note that
// the deletion is not instantaneous so the duration can become negative
// just before deletion.
MetaDuration duration = MetaplayClient.PlayerModel.ScheduledForDeletionAt - MetaTime.Now;
if (duration < MetaDuration.Zero)
CountdownTextGameObject.SetText("<deletion pending>");
else
CountdownTextGameObject.SetText(duration.ToSimplifiedString());
IndicatorGameObject.enabled = true;
}
}
Alternatively to polling, the game code may use a listener for OnPlayerScheduledForDeletionChanged
:
void IPlayerModelClientListenerCore.OnPlayerScheduledForDeletionChanged()
{
if (PlayerModel.DeletionStatus == PlayerDeletionStatus.None)
{
// Hide the indicator
GameUIScript.Instance.HideDeletionIndicator();
}
else
{
// Show the indicator
GameUIScript.Instance.ShowDeletionIndicator();
}
}
In most game scenarios you will want to use both methods: polling during game initialization to set your game UI to the correct state, then handling the ClientListener
callbacks to update the UI if the state changes while the player is connected.
📝 Example implementation
In the Idler example project, the indicator is implemented as a pop-up dialog that is managed by DeletionPopoverScript.cs
. The dialog is displayed on startup and when the state changes.
Canceling a scheduled deletion is just as straightforward add scheduling one, just send a message:
public void UnscheduleDeletion()
{
PlayerCancelScheduledDeletionRequest request = new PlayerCancelScheduledDeletionRequest();
MetaplaySDK.MessageDispatcher.SendMessage(request);
}
When the server acknowledges the request, it will be reflected in the PlayerModel
via the DeletionStatus
property which resets back to None
.
📝 Example implementation
In the Idler example project, the cancellation pop-up dialog closes itself only after DeletionStatus
becomes None
. This guarantees the server has acknowledged the cancellation request.
This document only covers the work required for a minimal implementation of Player Account Deletion. For more advanced topics, such as server-side callbacks, dealing with Account Deletion when recovering from a backup, and technical details of the deletion process, see Working with Player Deletion.