GetPedTask: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
m (Explained getPedTask better and linked to getPedSimplestTask)
m (link to task page like the other function)
Line 1: Line 1:
{{Client function}}
{{Client function}}
__NOTOC__
__NOTOC__
This function is used to get the name of the current task of a certain type for a ped.
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.
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.

Revision as of 01:05, 28 February 2011

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 prints the name of a player's task to the chat when they use the "task" command in the console.

function myTask ( commandName, priority, taskType )
    task = getPedTask ( source, priority, tonumber(taskType) )
    taskName = "none"
    if ( task ) then
        taskName = task
    end
    outputChatBox ( getPlayerName( source ) .. "'s " .. priority .. "(" .. taskType .. ") task is: " .. taskName )
end    
addCommandHandler ( "task", myTask )

See Also