GetPedAnimationSpeed: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
Line 20: Line 20:
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
addCommandHandler("getanimspeed",
addCommandHandler("getanimspeed",
     function(player)
     function()
         local animSpeed = getPedAnimationSpeed(player)
        -- Use the global 'localPlayer' variable for client-side scripts
         local animSpeed = getPedAnimationSpeed(localPlayer)
 
         if animSpeed ~= -1 then
         if animSpeed ~= -1 then
             outputChatBox("Your current animation speed is: " .. tostring(animSpeed), player)
             outputChatBox("Your current animation speed is: " .. tostring(animSpeed))
         else
         else
             outputChatBox("Could not retrieve your animation speed.", player)
             outputChatBox("Could not retrieve your animation speed.")
         end
         end
     end
     end

Revision as of 17:15, 22 August 2025

ADDED/UPDATED IN VERSION 1.6.0 r22780:

This function returns the speed of a current running ped animation.

Syntax

float getPedAnimationSpeed ( ped thePed )

Required Arguments

Returns

Returns animation speed on success, -1 otherwise.

Examples

addCommandHandler("getanimspeed",
    function()
        -- Use the global 'localPlayer' variable for client-side scripts
        local animSpeed = getPedAnimationSpeed(localPlayer)

        if animSpeed ~= -1 then
            outputChatBox("Your current animation speed is: " .. tostring(animSpeed))
        else
            outputChatBox("Could not retrieve your animation speed.")
        end
    end
)

See Also