Skip to main content

GetPlayerStatusAsync

Gets the current status of a player including any active violations.

Method Signature​

public async Task<PlayerStatusResponse?> GetPlayerStatusAsync()

Parameters​

This method takes no parameters. It automatically uses the current player's user ID from the telemetry data.

Returns​

Returns a PlayerStatusResponse object containing the player's current status information, or null if the request failed.

Usage Example​

var playerStatus = await playSafeManager.GetPlayerStatusAsync();

if (playerStatus != null && playerStatus.Ok)
{
bool hasViolation = playerStatus.Data.HasViolation;
Debug.Log($"Player has violation: {hasViolation}");

if (hasViolation && playerStatus.Data.ActiveActionLog != null)
{
var actionLog = playerStatus.Data.ActiveActionLog;
Debug.Log($"Action: {actionLog.ActionValue}");
Debug.Log($"Duration: {actionLog.DurationInMinutes} minutes");
Debug.Log($"Ends at: {actionLog.EndDate}");
}
}

Response Type​

PlayerStatusResponse​

public class PlayerStatusResponse
{
public bool Ok { get; set; }
public PlayerStatusData Data { get; set; }
public string Message { get; set; }
}

PlayerStatusData​

public class PlayerStatusData
{
public bool HasViolation { get; set; }
public ActionLog ActiveActionLog { get; set; }
public DateTime ServerTime { get; set; }
}

ActionLog​

public class ActionLog
{
public string ActionValue { get; set; }
public string ViolationType { get; set; }
public DateTime EndDate { get; set; }
public bool IsActive { get; set; }
public int DurationInMinutes { get; set; }
// New from v0.11.0
public string Id { get; set; }
public string ActionFriendlyName { get; set; } // Example: "Temp Ban 24h"
public bool TriggersStrike { get; set; }
public string Trigger { get; set; } // Example: "Explicit words"
public string Description { get; set; } // Default message sent to client - eg. "Looks like you used a bad word, you have been banned for x minutes"
public string Transcript { get; set; }
public int DelayInSeconds { get; set; }
public DateTime CreatedAt { get; set; }
public DateTime UpdatedAt { get; set; }
}

Properties​

PropertyTypeDescription
OkboolIndicates whether the request was successful
Data.HasViolationboolWhether the player currently has an active violation
Data.ActiveActionLogActionLogDetails of the current active action (if any)
Data.ServerTimeDateTimeCurrent server time
MessagestringResponse message from the server

Error Handling​

The method returns null if:

  • No user ID is found in telemetry data
  • Network request fails
  • Response parsing fails

Always check for null and verify the Ok property before accessing the data.

Notes​

  • This method no longer requires a playerUserId parameter as of version 0.3.0
  • The method automatically uses the current player's ID from GetTelemetry().UserId
  • Server time is provided to help with time-based calculations