Garry's Mod Wiki

NPC:GetNPCState

number NPC:GetNPCState()

Description

Returns the NPC's state.

Returns

1 number
The NPC's current state, see Enums/NPC_STATE.

Example

Function which prints out a list of idle NPCs to the server console.

function ReportIdleNPCs() for _, npc in pairs(ents.FindByClass("npc_*")) do if(IsValid(npc) && npc:IsNPC() && npc:GetNPCState() == NPC_STATE_IDLE) then print("Ent #"..npc:EntIndex()..": "..npc:GetClass().." is idle.") end end end
Output: (To server console)

Ent #111: npc_citizen is idle.

Ent #120: npc_citizen is idle.

Ent #122: npc_citizen is idle.

Ent #124: npc_citizen is idle.

Page Links


Special Pages


Wikis

?

Render Time: 27ms

DB GetPage 4
Generate Html 3
SaveChanges (1) 12
Render Body 0
Render Sidebar 6