GetNpcData
Jump to navigation
Jump to search
getNpcData
IMPROVED FROM UPDATE 0.1.2
This function is available in earlier releases and has corrected or expanded behavior in G1R:MP 0.1.2 and later. The contract below describes the updated behavior.
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 id, ownerResource, name, skin, armor, weapon, x, y, z, yaw, speed, routeIndex, routeCount, routeLoop, routeActive, paused, nameplateIdVisible, obstacleBehavior, navigationMode, and navigationCollisionMode; 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.
obstacleBehavioris"wait"or"avoid",navigationModeis"builtin"or"scripted", andnavigationCollisionModeis"combined","builtin", or"custom".- Mutating functions accept only NPCs owned by the calling resource.