NPC
On this page
The NPC object represents an NPC entity in the game world.
Functions
npc:is_valid() -> boolean
Validates the object exists in the game world. Always call this before using other methods.
npc:get_id() -> number | nil
Returns the NPC template ID, or nil if the NPC is invalid or disabled.
npc:get_position() -> table | nil
Returns position as a table with x and y fields, or nil if the NPC is invalid or disabled.
lua
local pos = npc:get_position()
-- pos.x, pos.ynpc:get_name() -> string | nil
Returns the NPC name, or nil if the NPC is invalid or disabled.
npc:distance() -> number | nil
Returns the distance from the local player to the NPC, or nil if the NPC or player is unavailable.
npc:talk() -> boolean
Attempts to talk to the NPC. Returns true if the talk request was sent, or false if the NPC is invalid, the player is unavailable, or the NPC is out of interaction range.