IsPlayerDoingTask: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
No edit summary
 
(Deprecated function)
 
(7 intermediate revisions by 4 users not shown)
Line 1: Line 1:
__NOTOC__
__NOTOC__
This function checks if the specified player is carrying out a certain task.
{{Client function}}
{{Deprecated|isPedDoingTask}}
 
This function checks if the specified player is carrying out a certain [[List of player tasks|task]].


==Syntax==
==Syntax==
Line 7: Line 10:
===Required Arguments===
===Required Arguments===
* '''thePlayer''': A [[player]] object referencing the specified player.
* '''thePlayer''': A [[player]] object referencing the specified player.
* '''taskName''': A string containing the name of the task you're checking for.
* '''taskName''': A string containing the name of the [[List of player tasks|task]] you're checking for.


===Returns===
===Returns===
Returns ''true'' if the player is currently doing the task.
Returns ''true'' if the player is currently doing the task, ''false'' otherwise.


==Example==
==Example==
This example forces a players radar-map on for 10seconds if it hasnt been already
This example checks if the player who entered the 'doingdriveby' command is doing a drive-by (clientside).
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
addCommandHandler ( "amIDoingADriveby", "amIDoingADriveby" )
function amIDoingADriveby ()
function amIDoingADriveby ( source, key )
   if ( isPlayerDoingTask ( getLocalPlayer(), "TASK_SIMPLE_GANG_DRIVEBY" ) ) then
   if ( isPlayerDoingTask ( source, "TASK_SIMPLE_GANG_DRIVEBY" ) ) then
     outputChatBox ( getPlayerName ( getLocalPlayer() ) .. " is doing a driveby!!!" )
     outputChatBox ( getClientName ( source ) .. " is doing a driveby!!!" )
   else
   else
     outputChatBox ( getClientName ( source ) .. " is not doing a driveby" )
     outputChatBox ( getPlayerName ( getLocalPlayer() ) .. " is not doing a driveby" )
   end
   end
end
end
addCommandHandler ( "doingdriveby", amIDoingADriveby )
</syntaxhighlight>
</syntaxhighlight>


==See Also==
==See Also==
{{Player functions}}
{{Client player functions}}

Latest revision as of 11:35, 30 September 2016

Emblem-important.png This function is deprecated. This means that its use is discouraged and that it might not exist in future versions.

Please use isPedDoingTask instead.


This function checks if the specified player is carrying out a certain task.

Syntax

bool isPlayerDoingTask ( player thePlayer, string taskName )

Required Arguments

  • thePlayer: A player object referencing the specified player.
  • taskName: A string containing the name of the task you're checking for.

Returns

Returns true if the player is currently doing the task, false otherwise.

Example

This example checks if the player who entered the 'doingdriveby' command is doing a drive-by (clientside).

function amIDoingADriveby ()
  if ( isPlayerDoingTask ( getLocalPlayer(), "TASK_SIMPLE_GANG_DRIVEBY" ) ) then
    outputChatBox ( getPlayerName ( getLocalPlayer() ) .. " is doing a driveby!!!" )
  else
    outputChatBox ( getPlayerName ( getLocalPlayer() ) .. " is not doing a driveby" )
  end
end
addCommandHandler ( "doingdriveby", amIDoingADriveby )

See Also