GetNpcs
getNpcs
Returns the identifiers of all active server-owned scripted NPCs.
Syntax
table getNpcs()
Parameters
This function does not accept parameters.
Returns
Returns a one-based array of numeric NPC identifiers.
Examples
Inspect every scripted NPC:
for _, npcId in ipairs(getNpcs()) do
local npc = getNpcData(npcId)
if npc then
outputDebugString(npc.name .. " uses " .. npc.skin)
end
end
Notes
- Available only in server-side resource scripts.
- NPC identifiers are allocated by the server and are distinct from connected player identifiers.