Skip to main content

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

Dalamud.Plugin.Services

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.
territoryType
ushort
The new territory type ID

MapIdChanged

public event Action<uint> MapIdChanged;
Fired when the current Map changes.
mapId
uint
The new map ID

InstanceChanged

public event Action<uint> InstanceChanged;
Fired when the current zone Instance changes.
instance
uint
The new instance number

ClassJobChanged

public event ClassJobChangeDelegate? ClassJobChanged;
Fired when a character’s ClassJob changes.
classJobId
uint
The new ClassJob ID

LevelChanged

public event LevelChangeDelegate? LevelChanged;
Fired when any character level changes, including levels for non-active ClassJobs (e.g., PvP matches, DoH/DoL).
classJobId
uint
The ClassJob ID
level
uint
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.
type
int
The type of logout
code
int
The success/failure code

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.
condition
ContentFinderCondition
The Content Finder condition for the ready duty

Properties

ClientLanguage

public ClientLanguage ClientLanguage { get; }
Gets the language of the client.
ClientLanguage
ClientLanguage
The client’s language setting

TerritoryType

public ushort TerritoryType { get; }
Gets the current Territory the player resides in.
TerritoryType
ushort
The current territory type ID

MapId

public uint MapId { get; }
Gets the current Map the player resides in.
MapId
uint
The current map ID

Instance

public uint Instance { get; }
Gets the instance number of the current zone, used when multiple copies of an area are active.
Instance
uint
The instance number

IsLoggedIn

public bool IsLoggedIn { get; }
Gets a value indicating whether a character is logged in.
IsLoggedIn
bool
True if a character is logged in

IsPvP

public bool IsPvP { get; }
Gets a value indicating whether the user is playing PvP.
IsPvP
bool
True if in PvP

IsPvPExcludingDen

public bool IsPvPExcludingDen { get; }
Gets a value indicating whether the user is playing PvP, excluding the Wolves’ Den.
IsPvPExcludingDen
bool
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.
IsGPosing
bool
True if in 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.
blockingFlag
ConditionFlag
An outvar containing the first observed condition blocking the “idle” state. 0 if idle.
return
bool
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;
    }
}

Remarks

  • 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.

Build docs developers (and LLMs) love