Garry's Mod Wiki

NPC:HasCondition

boolean NPC:HasCondition( number condition )

Description

Returns whether or not the NPC has the given condition.

Arguments

1 number condition
The condition index, see Enums/COND.

Returns

1 boolean
True if the NPC has the given condition, false otherwise.

Example

Function that prints a list of conditions an NPC has.

function ListConditions(npc) if(!IsValid(npc)) then return end print(npc:GetClass().." ("..npc:EntIndex()..") has conditions:") for c = 0, 100 do if(npc:HasCondition(c)) then print(npc:ConditionName(c)) end end end
Output: (To server console):

npc_antlion (120) has conditions:

COND_IN_PVS

COND_NO_WEAPON

COND_HAVE_ENEMY_LOS

COND_TOO_FAR_TO_ATTACK

COND_NO_HEAR_DANGER

COND_FLOATING_OFF_GROUND

Page Links


Special Pages


Wikis

?

Render Time: 39ms

DB GetPage 3
Generate Html 7
SaveChanges (1) 8
Render Body 0
Render Sidebar 16