ReportPlayerAsync
Available from 0.18.0. The reason argument is available from 0.19.2.
Reports a player for misconduct. UndoReportPlayerAsync withdraws the report.
Method Signatures
public async Task<ModerationEventResponse> ReportPlayerAsync(string targetUserId, string reason = null)
public async Task<PlaySafeApiResponse> UndoReportPlayerAsync(string targetUserId, string reason = null)
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
targetUserId | string | Yes | The unique ID of the player to report |
reason | string | No | Optional reason for the action. Defaults to null, in which case it is not sent |
The acting player is the local player, taken from your GetTelemetry delegate.
Returns
ReportPlayerAsyncreturns aModerationEventResponse, ornullif the request failed.UndoReportPlayerAsyncreturns aPlaySafeApiResponse, ornullif the request failed.
Usage Example
var result = await PlaySafeManager.Instance.ReportPlayerAsync(targetPlayerId);
if (result != null && result.Ok)
{
Debug.Log($"Reported {targetPlayerId}.");
}
else
{
Debug.LogWarning($"Could not report player: {result?.Message ?? "Unknown error"}");
}
// Later, to undo it
var undone = await PlaySafeManager.Instance.UndoReportPlayerAsync(targetPlayerId);
Response Types
ModerationEventResponse
Data is a ModerationEvent:
public class ModerationEvent
{
public string Id { get; set; }
public string ProductId { get; set; }
public string ReporterPlayerUserId { get; set; }
public string ReporterRole { get; set; }
public string TargetPlayerUserId { get; set; }
public string EventType { get; set; }
public DateTime CreatedAt { get; set; }
public DateTime UpdatedAt { get; set; }
}
PlaySafeApiResponse
public class PlaySafeApiResponse
{
public bool Ok { get; set; }
public object Data { get; set; }
public string Message { get; set; }
}
Error Handling
Both methods return null if the network request fails or the response cannot be parsed. Always check for null and verify Ok before proceeding.
Notes
- Reports are shown against the target on the PlaySafe Dashboard and count towards their respect score.
- Each player can have one
reportevent per target. CallingReportPlayerAsyncagain for the same target does not create a second event; that call returns a response withOkset tofalse. - Undoing a report that was never made succeeds and changes nothing.
- These methods only record the action with PlaySafe. A report does not itself penalize the target.