Overview
IClientState represents the state of the game client at the time of access. It provides information about the current territory, login state, and fires events when the player’s state changes.
Namespace
Events
ZoneInit
public event Action<ZoneInitEventArgs> ZoneInit;
Fired when the game initializes a zone.
TerritoryChanged
public event Action<ushort> TerritoryChanged;
Fired when the current Territory changes.
The new territory type ID
MapIdChanged
public event Action<uint> MapIdChanged;
Fired when the current Map changes.
InstanceChanged
public event Action<uint> InstanceChanged;
Fired when the current zone Instance changes.
ClassJobChanged
public event ClassJobChangeDelegate? ClassJobChanged;
Fired when a character’s ClassJob changes.
LevelChanged
public event LevelChangeDelegate? LevelChanged;
Fired when any character level changes, including levels for non-active ClassJobs (e.g., PvP matches, DoH/DoL).
The new level of the corresponding ClassJob
Login
public event Action Login;
Fired when a character is logging in, and the local character object is available.
Logout
public event LogoutDelegate Logout;
Fired when a character is logging out.
EnterPvP
public event Action EnterPvP;
Fired when a character is entering PvP.
LeavePvP
public event Action LeavePvP;
Fired when a character is leaving PvP.
CfPop
public event Action<Lumina.Excel.Sheets.ContentFinderCondition> CfPop;
Fired when a duty is ready.
The Content Finder condition for the ready duty
Properties
ClientLanguage
public ClientLanguage ClientLanguage { get; }
Gets the language of the client.
The client’s language setting
TerritoryType
public ushort TerritoryType { get; }
Gets the current Territory the player resides in.
The current territory type ID
MapId
public uint MapId { get; }
Gets the current Map the player resides in.
Instance
public uint Instance { get; }
Gets the instance number of the current zone, used when multiple copies of an area are active.
IsLoggedIn
public bool IsLoggedIn { get; }
Gets a value indicating whether a character is logged in.
True if a character is logged in
IsPvP
public bool IsPvP { get; }
Gets a value indicating whether the user is playing PvP.
IsPvPExcludingDen
public bool IsPvPExcludingDen { get; }
Gets a value indicating whether the user is playing PvP, excluding the Wolves’ Den.
True if in PvP excluding Wolves’ Den
IsGPosing
public bool IsGPosing { get; }
Gets a value indicating whether the client is currently in Group Pose (GPose) mode.
Methods
IsClientIdle
public bool IsClientIdle(out ConditionFlag blockingFlag);
public bool IsClientIdle();
Checks whether the client is currently “idle”. This means a player is not logged in, or is not actively in combat or doing anything that we may not want to disrupt.
An outvar containing the first observed condition blocking the “idle” state. 0 if idle.
True if the client is idle
Example Usage
public class MyPlugin : IDalamudPlugin
{
private readonly IClientState clientState;
public MyPlugin(IClientState clientState)
{
this.clientState = clientState;
// Subscribe to territory changes
this.clientState.TerritoryChanged += OnTerritoryChanged;
this.clientState.Login += OnLogin;
this.clientState.Logout += OnLogout;
}
private void OnTerritoryChanged(ushort territoryId)
{
// Called when player changes zones
Log.Information($"Changed to territory: {territoryId}");
}
private void OnLogin()
{
// Called when player logs in
Log.Information("Player logged in");
if (this.clientState.IsPvP)
{
Log.Information("Player is in PvP");
}
}
private void OnLogout(int type, int code)
{
// Called when player logs out
Log.Information($"Player logged out: type={type}, code={code}");
}
public void Dispose()
{
this.clientState.TerritoryChanged -= OnTerritoryChanged;
this.clientState.Login -= OnLogin;
this.clientState.Logout -= OnLogout;
}
}
- The
LocalPlayer and LocalContentId properties are deprecated. Use IPlayerState or IObjectTable.LocalPlayer instead.
- Always unsubscribe from events in your plugin’s
Dispose() method to prevent memory leaks.
- Territory and map changes may occur during loading screens.