GetPedTask

From Multi Theft Auto: Wiki
Revision as of 01:12, 28 February 2011 by Ransom (talk | contribs) (→‎Example: Old example was not working, uploaded a better one)
Jump to navigation Jump to search

This function is used to get any simple or complex task of a certain type for a ped.

It can provide feedback on all tasks relating to a ped. For example, while jumping, getPedSimplestTask will return TASK_SIMPLE_IN_AIR. If you wanted to know specifically if the player has jumped, you would use this function. If you did you will discover that while jumping Primary task 3 is TASK_COMPLEX_JUMP.

Syntax

string getPedTask ( ped thePed, string priority, int taskType, [int index = 0] )

Required Arguments

  • thePed: The ped whose task you want to retrieve.
  • priority: A string determining which set of tasks you want to retrieve it from. This must be either "primary" or "secondary".
  • taskType: An integer value representing the task type (or slot) you want to get the task from. Types can be:
    • PRIMARY TASKS
      • 0: TASK_PHYSICAL_RESPONSE
      • 1: TASK_EVENT_RESPONSE_TEMP
      • 2: TASK_EVENT_RESPONSE_NONTEMP
      • 3: TASK_PRIMARY
      • 4: TASK_DEFAULT
    • SECONDARY TASKS
      • 0: TASK_SECONDARY_ATTACK
      • 1: TASK_SECONDARY_DUCK
      • 2: TASK_SECONDARY_SAY
      • 3: TASK_SECONDARY_FACIAL_COMPLEX
      • 4: TASK_SECONDARY_PARTIAL_ANIM
      • 5: TASK_SECONDARY_IK

Optional Arguments

  • index: An integer value representing how many sub tasks to go through. -1 to get the simplest task, 0 to get the most complex task.

Returns

Returns a string containing the name of a task. See list of player tasks for valid strings. Returns false if invalid arguments are specified or if there is no task of the type or index specified.

Example

This example outputs all the primary and secondary tasks to the chatbox when a player types "/task" in chat or "task" in the console. If there is no task getPedTask will return false and that will be the output.

function myTask ( commandName, taskType )
	for k=1,4 do
		local task = getPedTask ( getLocalPlayer(), "primary", k )
		outputChatBox ( "Primary task #"..k.." is "..tostring(task) )
	end
	for k=1,5 do
		local task = getPedTask ( getLocalPlayer(), "secondary", k )
		outputChatBox ( "Secondary task #"..k.." is "..tostring(task) )	
	end
end    
addCommandHandler ( "task", myTask )

See Also