Garry's Mod Wiki

Garry's Mod Wiki

  number NPC:GetNPCState()

Description

Returns the NPC's state.

Returns

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

Example

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

function ReportIdleNPCs() for i, npc in ipairs( ents.FindByClass( "npc_*" ) ) do if IsValid( npc ) and npc:IsNPC() and 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.

This site is a community mirror of the official Garry's Mod wiki.. This site is not maintained by Facepunch Studios.

Page content is automatically updated four times a day. Edits and history are not available.

Last Parsed: Loading...