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 COND enum.

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