NPC/SetCondition

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

Contents

Description

Sets an NPC condition.

Arguments

number condition

The condition index, see COND_ Enums.

Examples

Example

Freezes an NPC for a period of time.

COND_NPC_UNFREEZE = 68	-- Delete this line when COND_ enums are added

function FreezeNPCTemporarily(npc, delay)
	
	if(!IsValid(npc)) then return end
	
	delay = delay or 1
	
	npc:SetSchedule(SCHED_NPC_FREEZE)

	timer.Simple(delay, function()
		if(IsValid(npc)) then npc:SetCondition(COND_NPC_UNFREEZE) end
	end)
	
end


Personal tools
Navigation