GetNpcData

From Wiki G1R-MP G1 Remake Multiplayer
Revision as of 09:48, 15 August 2026 by QCherry (talk | contribs) (Update Lua API reference)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

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.