GetNpcData: Difference between revisions
Jump to navigation
Jump to search
Update Lua API reference |
Complete Lua function catalog |
||
| Line 32: | Line 32: | ||
* Mutating functions accept only NPCs owned by the calling resource. | * Mutating functions accept only NPCs owned by the calling resource. | ||
[[Category:Lua Functions]] | |||
[[Category:Server Functions]] | [[Category:Server Functions]] | ||
[[Category:World Functions]] | [[Category:World Functions]] | ||
[[Category:NPC Functions]] | [[Category:NPC Functions]] | ||
Revision as of 09:52, 15 August 2026
getNpcData
Returns the complete authoritative state of a scripted NPC.
Syntax
table|false getNpcData(int npcId)
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
npcId |
int |
yes | The server-assigned NPC identifier returned by spawnNpc or getNpcs.
|
Returns
Returns a table containing identity, owner resource, skin, armor, weapon, position, yaw, speed, route progress and pause state; otherwise returns false.
Examples
Read the current route state:
local npc = getNpcData(npcId)
if npc then
outputDebugString(("Route %d/%d"):format(npc.routeIndex, npc.routeCount))
end
Notes
- Available only in server-side resource scripts.
- Position and speed values use metres and metres per second; yaw uses degrees.
- Mutating functions accept only NPCs owned by the calling resource.