Table of Contents

Class NwPlayer

Namespace
Anvil.API
Assembly
NWN.Anvil.dll

A player client connected to the server.

public sealed class NwPlayer : IEquatable<NwPlayer>
Inheritance
NwPlayer
Implements
Inherited Members
Extension Methods

Properties

BicFileName

Gets the name of the player's .bic file.

CDKey

Gets the public part of the CD key that the player used when logging in.

CameraFlags

Sets camera settings that override any client configuration settings.

CameraHeight

Sets the camera height for this player.

ClientVersion

Gets the player's client version (Major + Minor + Build).

ClientVersionCommitSha1

Gets the player's client version, as a Sha1 commit hash.

ControlledCreature

Gets the creature this player is currently controlling.
This will return the player's current possessed creature (familiar, DM possession), otherwise their player character if they are currently not possessing a creature.

CutsceneCameraMoveRate

Gets or sets the movement rate factor for the cutscene camera following ControlledCreature 'camera man'.

IPAddress

Gets the connecting IP address for the player.

IsConnected

Gets if this player is connected and playing (true), or if this player is still on character selection or connecting (false).

IsConnectionRelayed

Gets a value indicating whether the player has connected to the server over a relay (instead of directly).

IsDM

Gets a value indicating whether the player is a Dungeon Master.

IsInCursorTargetMode

Gets if this player is in cursor targeting mode.
NOTE! Only works if the player entered target mode using TryEnterTargetMode(Action<OnPlayerTarget>, TargetModeSettings?).

IsInCutsceneMode

Gets a value indicating whether ControlledCreature creature is currently in "Cutscene" mode.

IsPlayerDM

Gets or sets whether the player has DM privileges gained through a player login (as opposed to the DM client).

IsValid

Gets a value indicating whether this NwPlayer object is valid.
Returns false after the player disconnects from the server.

Language

Gets the language configured by this player.

Latency

Gets the last latency/"ping" result for this player. Results are updated every 6000 milliseconds.
Returns 0 for unsupported clients.

LatencyAverage

Gets this player's smoothed/average latency. This is a moving calculation that may change in future game releases.
Returns 0 for unsupported clients.

LoginCreature

Gets the original creature that this player logged in with.

PartyMembers

Gets all players in this player's party (including themself).
Associates are not included. Use LoginCreature.Faction.GetMembers() for a list of all party members, including associate creatures.

Platform

Gets the platform this player is currently playing from.

PlayerId

Gets the unique numeric ID of this player.

PlayerName

Gets the player's login name.

RestDurationOverride

Gets or sets a custom rest duration for this player.
Null indicates that no override is set. Assign null to use the default rest duration.

SpawnLocation

Gets or sets the location that this player will spawn at when logging in to the server.

Methods

ActionExamine(NwGameObject)

Shows an examine dialog for the specified target.

ActionStartConversation(NwGameObject, string, bool, bool)

Starts a conversation with another object, typically a creature.

AddCustomJournalEntry(JournalEntry, bool)

Adds/updates a journal entry.

AddHenchmen(NwCreature)

Attaches the specified creature to the player as a henchmen.

AddJournalQuestEntry(string, int, bool, bool)

Adds an entry to the player's journal.

AddLoopingVisualEffect(NwGameObject, VisualEffectTableEntry)

Adds the specified visual effect to an object, but only visible to this player.

AddToParty(NwPlayer)

Adds the player to the specified party leader's party.

ApplyInstantVisualEffectToObject(VfxType, NwGameObject)

Plays the specified "instant" VFX (Com*, FNF*, IMP*) on the target for this player only.

AttachCamera(NwGameObject, bool)

Attaches this player's camera to the specified game object. The object must be in the same area, and within visible distance.

BootPlayer(string)

Boots the player from the server.

CancelTargetMode()

Cancels any cursor targeting mode the player is currently in.

ClearLoopingVisualEffects(NwGameObject)

Clears looping visual effects on the specified object visible only to this player.

ClearObjectNameOverride(NwGameObject)

Clears an override name for the specified object.

ClearPlayerNameOverride(NwPlayer)

Clears an overridden player character name for a specific observer.

ClearPlayerNameOverride(bool)

Clears an overridden player character name.

ClearTextureOverride(string)

Removes the override for the specified texture, reverting to the original texture.

DMPossessCreature(NwCreature, bool)

If this player is a DM, causes them to possess the specified creature.

Delete(string, bool)

Immediately kicks the player and deletes their character file (.bic).

DestroySQLDatabase()

Immediately destroys the database attached to this player, clearing out all data and schema.
This operation is immediate and irreversible, even when inside a transaction or running query.
Existing active/prepared sqlqueries will remain functional, but any references to stored data or schema members will be invalidated.

DisplayFloatingTextStringOnCreature(NwCreature, string)
EnterCutsceneMode(bool)

Enters "Cutscene" mode, disabling GUI and camera controls for the player and marking them as plot object (invulnerable).
See CutsceneGhost(), and other Cutscene* effects for hiding and controlling the player creature during cutscene mode.

EnterTargetMode(Action<OnPlayerTarget>, TargetModeSettings?)

Triggers the player to enter cursor targeting mode, invoking the specified handler once the player selects something.

Equals(NwPlayer?)

Indicates whether the current object is equal to another object of the same type.

Equals(object?)

Determines whether the specified object is equal to the current object.

ExitCutsceneMode()

Exits "Cutscene" mode, restoring standard GUI and camera controls to the player, and restoring their plot flag.

ExportCharacter()

Forces the player's character to saved and exported to its respective directory (LocalVault, ServerVault, etc).

FadeFromBlack(float)

Fades the screen for a given player from black to regular screen.

FadeToBlack(float)

Fades the screen for a given player from a regular screen to black.

FloatingTextStrRef(int, bool, bool)

Briefly displays a floating text message above the player's head using the specified string reference.

FloatingTextString(string, bool, bool)

Briefly displays a floating text message above the player's head.

ForceAreaReload()

Forces this player to reload their current area.

ForceExamine(NwGameObject)

Forces the player to examine the specified game object.
Works on NwCreature, NwPlaceable, NwItem and NwDoor.
Does nothing for other object types.

GetAreaExplorationState(NwArea?)

Gets this player's area exploration state for the specified area.

GetCampaignVariable<T>(string, string)

Gets the specified campaign variable for the player.

GetDeviceProperty(PlayerDeviceProperty)

Gets the specified device property/capability as advertised by the client.

GetHashCode()

Serves as the default hash function.

GetJournalEntry(string)

Gets an existing journal entry with the specified quest tag.

GetLoopingVisualEffects(NwGameObject)

Gets a list of visual effects for the specified object visible only to this player.

GetObjectNameOverride(NwGameObject)

Gets the current name override set for the specified object.

GetOverridesForObserver(bool)

Gets a list of all name overrides for the specified observer.

GetPersonalVisibilityOverride(NwGameObject)

Gets the visiblity override for the specified object for this player.

GetPlayerNameOverride(NwPlayer?)

Gets the current name override set for the specified player.

GiveXp(int)

Gives the specified XP to the player, adjusted by any multiclass penalty.

LockCameraDirection(bool)

Locks the player's camera direction to its current direction, or unlocks the player's camera direction to enable it to move freely again.

LockCameraDistance(bool)

Locks the player's camera distance to its current distance setting, or unlocks the player's camera distance.

LockCameraPitch(bool)

Locks the player's camera pitch to its current pitch setting, or unlocks the player's camera pitch.

NightToDay(TimeSpan)

Changes the current Day/Night cycle for the player to daylight.

OpenInventory()

Instructs the player to open their inventory.

OpenInventory(NwCreature)

Opens the specified creatures inventory, and shows it to the player.

OpenInventory(NwPlaceable)

Forces the player to open the inventory of the specified placeable.

PlaySound(string, NwGameObject?)

Plays the specified sound at the target in the current area for this player only.

PlayerPossessCreature(NwCreature, bool, bool)

Possesses a creature temporarily by making them a familiar.

PopUpDeathPanel(bool, bool, int, string)

Displays a death panel that can turn off the "Respawn" or "Wait for Help" buttons.
The "Wait for Help" button is only enabled when the game is running in multiplayer mode.
By default if helpString isn't specified, the value used is "Choose an option below.
Respawning will incur a penalty of 50 XP per level of your character and the loss of 10% of your gold."
(strref 66219 single player, 6600 for multiplayer).

PopUpGUIPanel(GUIPanel)

Displays a GUI panel to a player.

PostString(string, int, int, ScreenAnchor, float, Color?, Color?, int, string)

Displays a message on the player's screen.
The message is always displayed on top of whatever is on the screen, including UI elements.

PrepareSQLQuery(string)

Sets up a SQL Query for this player.
This will NOT run the query; only make it available for parameter binding.
To run the query, you need to call Execute() even if you do not expect result data.

RefreshClientObject(NwGameObject)

Causes this player to refresh the client object associated with the given game object.

RefreshPlayerClientObject()

Causes this player to refresh the player client object associated with their current controlled creature.

RemoveFromCurrentParty()

Removes the player from their current party.

RestoreCameraFacing()

Restores the camera mode and facing to what they where when StoreCameraFacing was last called.
RestoreCameraFacing can only be used once, and must correspond to a previous call to StoreCameraFacing.

SeekAudioStream(AudioStreamIdentifier, float)

Seeks the audio stream with the specified identifier to a new position on the currently playing audio track.

SendServerMessage(string)

Sends a server message to the player.

SendServerMessage(string, Color)

Sends a server message to the player.

SendToServer(string, string, string, bool)

Sends the player to a new server, where the player's character will connect and log in.

Serialize(bool)
SetAreaExplorationState(NwArea, bool)

Sets whether the player has explored an area.

SetAreaExplorationState(NwArea, byte[])

Sets this player's area exploration state for the specified area.

SetAudioStreamPaused(AudioStreamIdentifier, bool, TimeSpan)

Pauses/Unpauses the audio stream on the specified identifier.

SetAudioStreamVolume(AudioStreamIdentifier, float, TimeSpan)

Changes the volume of the audio stream with the specified identifier.

SetCameraFacing(float, float, float, CameraTransitionType)

Changes the direction the player's camera is facing.

SetCameraLimits(float, float, float, float)

Sets camera limits that override any client configuration.
A value of -1 means to use the client limits.

SetCutsceneMode(bool, bool)

Toggles the CutsceneMode state for the player.

SetGuiPanelDisabled(GUIPanel, bool, NwGameObject?)

Disable a specific gui panel for this player.
Will close the GUI panel if it is currently open.
Will fire a DisabledPanelAttemptOpen event for some panels if a player attempts to open them while disabled.

SetObjectNameOverride(NwGameObject, string)

Sets an override name for a specific game object, as visible from this player.
Supports placeables, doors, items and creatures.

SetPCReputation(bool, NwPlayer)

Sets if the player should like, or unlike the specified player.

SetPersonalVisibilityOverride(NwGameObject, VisibilityMode)

Sets the visiblity override for the specified object for this player.

SetPlayerNameOverride(PlayerNameOverride)

Sets an override player character name and community name on the player list for all players. Is not persistent.

SetPlayerNameOverride(PlayerNameOverride, NwPlayer)

Sets an override player character name and community name on the player list as observed by a specific player. Is not persistent.

SetShaderUniform(ShaderUniform, int)

Sets a global shader uniform for this player.
These uniforms are not used by the base game and are reserved for module-specific scripting.
You need to add custom shaders that will make use of them.
In multiplayer, these need to be reapplied when a player rejoins.

SetShaderUniform(ShaderUniform, Vector4)

Sets a global shader uniform for this player.
These uniforms are not used by the base game and are reserved for module-specific scripting.
You need to add custom shaders that will make use of them.
In multiplayer, these need to be reapplied when a player rejoins.

SetShaderUniform(ShaderUniform, float)

Sets a global shader uniform for this player.
These uniforms are not used by the base game and are reserved for module-specific scripting.
You need to add custom shaders that will make use of them.
In multiplayer, these need to be reapplied when a player rejoins.

SetSpellTargetingData(TargetingData)

Sets a spell targeting data override for this player.

SetTextureOverride(string, string)

Makes ControlledCreature PC load a new texture instead of another.

ShowVisualEffect(VfxType, Vector3)

Plays the specified VFX at the target position in the current area for this player only.

StartAudioStream(AudioStreamIdentifier, string, bool, TimeSpan, float, float)

Assign one of the available audio streams to play a specific file. This mechanism can be used
to replace regular music playback, and synchronize it between clients.

StopAudioStream(AudioStreamIdentifier, TimeSpan)

Stops the audio stream playing on the specified identifier.

StopFade()

Removes any current fading effects or black screen from the monitor of the player.

StoreCameraFacing()

Stores (bookmarks) the camera's facing and position so it can be restored later with RestoreCameraFacing.

TryCreateNuiWindow(NuiWindow, out NuiWindowToken, string)

Create a NUI window for this player.

TryEnterTargetMode(Action<OnPlayerTarget>, TargetModeSettings?)

Attempts to get this player to enter cursor targeting mode, invoking the specified handler once the player selects something.
If the player is already in targeting mode, the existing handler will not be cleared.

UnlockAchievement(string, int, int, int)

Unlock an achievement for the player who must be logged in.

UnpossessCreature()

If this player is possessing a creature, instructs them to unpossess them.

UpdateCharacterSheet()

Refreshes the player's character sheet.

Vibrate(VibratorMotor, float, TimeSpan)

Vibrates the player's device or controller. Does nothing if vibration is not supported.

Events

OnBarterEnd
OnBarterStart
OnClientDisconnect

Called when the player disconnects from the server.
This event is also called if the player connects, and then disconnects on the character select screen.

OnClientEnter

Triggered when a NwPlayer selects a character and logged into the module.

OnClientLeave

Triggered when a NwCreature leaves the server.

OnClientLevelUpBegin
OnCombatStatusChange
OnCutsceneAbort

Triggered when a NwPlayer tries to cancel a cutscene (ESC).

OnDMAppear
OnDMChangeDifficulty
OnDMDisableTrap
OnDMDisappear
OnDMDumpLocals
OnDMForceRest
OnDMGetFactionReputation
OnDMGetVariable
OnDMGiveAlignment
OnDMGiveGold
OnDMGiveItem
OnDMGiveLevel
OnDMGiveXP
OnDMGoTo
OnDMHeal
OnDMJumpAllPlayersToPoint
OnDMJumpTargetToPoint
OnDMJumpToPoint
OnDMKill
OnDMLimbo
OnDMPlayerDMLogin
OnDMPlayerDMLogout
OnDMPossess
OnDMPossessFullPower
OnDMSetDate
OnDMSetFaction
OnDMSetFactionReputation
OnDMSetStat
OnDMSetTime
OnDMSetVariable
OnDMSpawnObject
OnDMSpawnTrapOnObject
OnDMTakeItem
OnDMToggleAI
OnDMToggleImmortal
OnDMToggleInvulnerable
OnDMToggleLock
OnDMViewInventory
OnExamineObject
OnExamineTrap
OnMapPinAddPin

Called when a player is about to place a map pin.

OnMapPinChangePin

Called when a player is about to change an existing map pin.

OnMapPinDestroyPin

Called when a player is about to delete an existing map pin.

OnNuiEvent

Called when a player triggers an event in the NUI system.

OnPartyEvent
OnPlayerChat

Triggered when any NwPlayer sends a chat message. Private channel not hooked.

OnPlayerDeath

Triggered when a NwPlayer dies.

OnPlayerDying

Triggered when a NwPlayer enters a dying state (< 0 HP).

OnPlayerEquipItem

Triggered when a NwCreature equips an NwItem.

OnPlayerGuiEvent

Triggered when a player clicks on a particular GUI interface.

OnPlayerLevelUp

Triggered when a NwPlayer levels up.

OnPlayerQuickChat

Called when a player uses a quick chat command.

OnPlayerRespawn

Triggered when a NwPlayer clicks the respawn button on the death screen.

OnPlayerRest

Triggered when NwPlayer presses the rest button and begins to rest, cancelled rest, or finished rest.

OnPlayerTarget

Triggered when a NwPlayer that has targeted something.

OnPlayerTileAction

Triggered when a player performs an action on an area tile.

OnPlayerUnequipItem

Triggered just before a NwCreature un-equips an NwItem.

OnServerCharacterSave

Called when the server is about to save a character to the server vault.
This is called once for every character when the server is exiting, when a player leaves the server, or when ExportSingleCharacter() & ExportAllCharacters() is called.
This event can be skipped to prevent the character from being saved.

OnServerSendArea

Operators

operator ==(NwPlayer?, NwPlayer?)
implicit operator CNWSPlayer?(NwPlayer?)
operator !=(NwPlayer?, NwPlayer?)