GetNpcs: Difference between revisions
Jump to navigation
Jump to search
Update Lua API reference |
Complete Lua function catalog |
||
| Line 29: | Line 29: | ||
* NPC identifiers are allocated by the server and are distinct from connected player identifiers. | * NPC identifiers are allocated by the server and are distinct from connected player identifiers. | ||
[[Category:Lua Functions]] | |||
[[Category:Server Functions]] | [[Category:Server Functions]] | ||
[[Category:World Functions]] | [[Category:World Functions]] | ||
[[Category:NPC Functions]] | [[Category:NPC Functions]] | ||
Latest revision as of 09:52, 15 August 2026
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.