NPC.TaskFail

From GMod Wiki

Revision as of 02:10, 4 October 2009 by Unrealomega (Talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search
Function
Syntax NPC:TaskFail( String description )
Description:
Indicates that an NPC task has failed
Returns: nil
In Object: Npc
Realm: NewerServer.png
BBCode Link: [b][url=http://wiki.garrysmod.com/?title=NPC.TaskFail]NPC.TaskFail [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