NPC/HasCondition

From Garry's Mod
Jump to: navigation, search
 NPC:HasCondition( )

Contents

Description

Returns whether or not the NPC has the given condition.

Arguments

number condition

The condition index, see COND_ Enums.

Returns

boolean

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

Examples

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
Personal tools
Navigation