NPC.TaskComplete

From GMod Wiki

Jump to: navigation, search
Function
Syntax NPC:TaskComplete( )
Description:
Indicates that an NPC task has been completed
Returns: nil
In Object: Npc
Realm: NewerServer.png
BBCode Link: [b][url=http://wiki.garrysmod.com/?title=NPC.TaskComplete]NPC.TaskComplete [img]http://wiki.garrysmod.com/favicon.ico[/img][/url][/b]



Examples

DescriptionFindEnemy task with TaskFail added to describe the failure.
Used onNewerServer.png
Code
function ENT:TaskStart_FindEnemy( data ) 
 
 	local et =  ents.FindInSphere( self:GetPos(), data.Radius or 512 ) 
 	for k, v in ipairs( et ) do 
 
 		if (  v:IsValid() && v != self && v:GetClass() == data.Class  ) then 
 			//Msg( "Setting Enemy ", v, "\n" ) 
 			self:SetEnemy( v, true ) 
 			self:UpdateEnemyMemory( v, v:GetPos() ) 
 			self:TaskComplete() 
 			return 
 		end 
 
 	end 
 
 	self:SetEnemy( NULL )	 
       self:TaskFail("FindEnemy: Could not find an enemy of type " .. data.Class .. " within " .. (data.Radius or 512) .. " units.")
 end 
 
 
OutputN/A
Personal tools
Namespaces
Variants
Actions
Navigation
Lua Scripting
Functions
Hooks
Toolbox