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 DateTime EndDate { get; set; }
public bool IsActive { get; set; }
public int DurationInMinutes { 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