GetPlayerTask: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
|||
Line 1: | Line 1: | ||
{{Server client function}} | |||
__NOTOC__ | __NOTOC__ | ||
This function is used to get the current task | This function is used to get the name of the current task of a certain type for a player. | ||
==Syntax== | ==Syntax== | ||
<syntaxhighlight lang="lua"> | <syntaxhighlight lang="lua"> | ||
string getPlayerTask ( player thePlayer, string priority, int | string getPlayerTask ( player thePlayer, string priority, int taskType, [int index = 0] ) | ||
</syntaxhighlight> | </syntaxhighlight> | ||
Line 10: | Line 11: | ||
*'''thePlayer''': The [[player]] whose task you want to retrieve. | *'''thePlayer''': The [[player]] whose task you want to retrieve. | ||
*'''priority''': A string determining which set of tasks you want to retrieve it from. This must be either "priority" or "secondary". | *'''priority''': A string determining which set of tasks you want to retrieve it from. This must be either "priority" or "secondary". | ||
*''' | *'''taskType''': An integer value representing the task-type (or slot) you want to get the task from. Types can be: | ||
**'''PRIMARY TASKS''' | **'''PRIMARY TASKS''' | ||
***'''0:''' TASK_PRIORITY_PHYSICAL_RESPONSE | ***'''0:''' TASK_PRIORITY_PHYSICAL_RESPONSE | ||
Line 26: | Line 27: | ||
===Optional Arguments=== | ===Optional Arguments=== | ||
*'''index''': An integer value representing how many sub | *'''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=== | ||
Line 32: | Line 33: | ||
==Example== | ==Example== | ||
This example prints the name of a | <section name="Server" class="server" show="true"> | ||
This example prints the name of a player's task to the chat when they use the "task" command in the console. | |||
<syntaxhighlight lang="lua"> | <syntaxhighlight lang="lua"> | ||
function task ( source, key, priority, taskType ) | |||
function task ( source, key, priority, | task = getPlayerTask ( source, priority, tonumber(taskType) ) | ||
taskName = "none" | |||
if ( task ) then | |||
taskName = task | |||
end | |||
outputChatBox ( getClientName ( source ) .. "'s " .. priority .. "(" .. taskType .. ") task is: " .. taskName ) | |||
end | end | ||
addCommandHandler ( "task", task ) | |||
</syntaxhighlight> | </syntaxhighlight> | ||
</section> | |||
==See Also== | ==See Also== | ||
{{Player functions}} | {{Player functions}} |
Revision as of 14:04, 19 August 2007
This function is used to get the name of the current task of a certain type for a player.
Syntax
string getPlayerTask ( player thePlayer, string priority, int taskType, [int index = 0] )
Required Arguments
- thePlayer: The player whose task you want to retrieve.
- priority: A string determining which set of tasks you want to retrieve it from. This must be either "priority" 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_PRIORITY_PHYSICAL_RESPONSE
- 1: TASK_PRIORITY_EVENT_RESPONSE_TEMP
- 2: TASK_PRIORITY_EVENT_RESPONSE_NONTEMP
- 3: TASK_PRIORITY_PRIMARY
- 4: TASK_PRIORITY_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
- PRIMARY TASKS
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
Click to collapse [-]
ServerThis example prints the name of a player's task to the chat when they use the "task" command in the console.
function task ( source, key, priority, taskType ) task = getPlayerTask ( source, priority, tonumber(taskType) ) taskName = "none" if ( task ) then taskName = task end outputChatBox ( getClientName ( source ) .. "'s " .. priority .. "(" .. taskType .. ") task is: " .. taskName ) end addCommandHandler ( "task", task )
See Also
- getPlayerTeam
- getPlayerBlurLevel
- setPlayerBlurLevel
- getPlayerSerial
- forcePlayerMap
- getPlayerScriptDebugLevel
- getPlayerFromName
- getPlayerMoney
- getPlayerName
- getPlayerNametagColor
- getPlayerNametagText
- getPlayerPing
- getPlayerWantedLevel
- givePlayerMoney
- isPlayerMapForced
- isPlayerNametagShowing
- setPlayerHudComponentVisible
- setPlayerMoney
- setPlayerNametagColor
- setPlayerNametagShowing
- setPlayerNametagText
- takePlayerMoney
- countPlayersInTeam
- getPlayersInTeam
- isVoiceEnabled
- setControlState
- getControlState