KillPedTask: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
(killPedTask adding latest functions)
 
 
(One intermediate revision by the same user not shown)
Line 25: Line 25:
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
function playerPressedKey(button, press)
function playerPressedKey(button, press)
      local moveState = getPedMoveState( localPlayer )
    local moveState = getPedMoveState( localPlayer )
 
    if(moveState=="jump") then
      if(moveState=="jump") then
        killPedTask(localPlayer, "primary", 3, true)
          killPedTask(localPlayer, "primary", 3, true)
    end
      end
end
end
addEventHandler("onClientKey", root, playerPressedKey)
addEventHandler("onClientKey", root, playerPressedKey)
Line 36: Line 35:


==See Also==
==See Also==
{{Ped functions}}
{{Ped functions|client}}

Latest revision as of 14:01, 22 December 2024

BETA: NEW FEATURE (BUILD: 1.6.0 r22837)

This function will be used to kill current ped tasks.

Syntax

bool killPedTask ( ped thePed, string taskType, int taskNumber, [ bool gracefully = true] )

Required arguments

  • thePed: The ped element.
  • taskType: The task type given primary or secondary, for more info see Tasks.
  • taskNumber the task slot number for reference see Tasks.

Optional arguments

  • gracefully If set to true the animation will be cut in a smooth transition, false otherwise.

Returns

If successful returns true, false otherwise.

Example

This example let you interrupt and cancel the jump animation action and clear the slot

function playerPressedKey(button, press)
    local moveState = getPedMoveState( localPlayer )
    if(moveState=="jump") then
        killPedTask(localPlayer, "primary", 3, true)
    end
end
addEventHandler("onClientKey", root, playerPressedKey)

See Also