GetPedAnimation: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
Megadreams (talk | contribs) m (Fix variable name I missed in my last edit) |
||
(11 intermediate revisions by 6 users not shown) | |||
Line 3: | Line 3: | ||
Gets the animation of a player or ped that was set using [[setPedAnimation]]. | Gets the animation of a player or ped that was set using [[setPedAnimation]]. | ||
{{Note|Use [[getPedTask]] to monitor what movements the player is currently doing.''}} | |||
==Syntax== | |||
{{Deprecated items|3.0158|1.5.7|<syntaxhighlight lang="lua">string, string getPedAnimation ( ped thePed )</syntaxhighlight>|20450}} | |||
{{New feature/item|3.0158|1.5.7|20450|<syntaxhighlight lang="lua"> string, string, int, int, bool, bool, bool, int, bool getPedAnimation ( ped thePed )</syntaxhighlight>}} | |||
{{OOP||[[ped]]:getAnimation||setPedAnimation}} | |||
===Required Arguments=== | ===Required Arguments=== | ||
*'''thePed:''' the player or ped you want to get the animation of. | *'''thePed:''' the [[player]] or [[ped]] you want to get the [[animations|animation]] of. | ||
===Returns=== | ===Returns=== | ||
Returns two | {{Deprecated items|3.0158|1.5.7|Returns two [[string|strings]]: the first is the name of the block, the second is the name of the animation. Returns ''false'' if there was an error or if the ped is not doing an animation.|20450}} | ||
{{New feature/item|3.0158|1.5.7|20450|The function returns 9 values in the same order as required by [[setPedAnimation]]: | |||
<syntaxhighlight lang="lua">string block, string anim, int time, bool loop, bool updatePosition, bool interruptable, bool freezeLastFrame, int blendTime, bool restoreTaskOnAnimEnd</syntaxhighlight> | |||
}} | |||
==Example== | ==Example== | ||
Line 23: | Line 27: | ||
if thePlayer then -- If a player name entered then | if thePlayer then -- If a player name entered then | ||
thePlayerToCopyFrom = getPlayerFromName(thePlayer) -- get player from his name | thePlayerToCopyFrom = getPlayerFromName(thePlayer) -- get player from his name | ||
block, anim = getPedAnimation(thePlayerToCopyFrom) -- get the player animation | |||
if | if block then -- if got the animation successfully then | ||
setPedAnimation(localPlayer, | setPedAnimation(localPlayer, block, anim) -- set my animation the same | ||
outputChatBox("* Copied Successfully !") -- output chat message | outputChatBox("* Copied Successfully !") -- output chat message | ||
end | end | ||
Line 51: | Line 55: | ||
==See Also== | ==See Also== | ||
{{Client_ped_functions}} | {{Client_ped_functions}} | ||
[[hu:getPedAnimation]] |
Latest revision as of 04:38, 6 March 2022
Gets the animation of a player or ped that was set using setPedAnimation.
Syntax
string, string, int, int, bool, bool, bool, int, bool getPedAnimation ( ped thePed )
OOP Syntax Help! I don't understand this!
- Method: ped:getAnimation(...)
- Counterpart: setPedAnimation
Required Arguments
Returns
The function returns 9 values in the same order as required by setPedAnimation:
string block, string anim, int time, bool loop, bool updatePosition, bool interruptable, bool freezeLastFrame, int blendTime, bool restoreTaskOnAnimEnd
Example
This example adds a command that allows you to copy the animation being used by another player using /copyanim theirName
function CopyAnimation(theCommand, thePlayer) -- The Command Function if thePlayer then -- If a player name entered then thePlayerToCopyFrom = getPlayerFromName(thePlayer) -- get player from his name block, anim = getPedAnimation(thePlayerToCopyFrom) -- get the player animation if block then -- if got the animation successfully then setPedAnimation(localPlayer, block, anim) -- set my animation the same outputChatBox("* Copied Successfully !") -- output chat message end else outputChatBox("* Please Enter a Player Name To Copy From !") -- if you didnt entered a player name , then output a chat box message end end addCommandHandler("copyanim", CopyAnimation) -- adding the Command Handler
Example 2
This example shows what block and animation your player is currently performing. Note this will return "N/A" if you did not set an animation with setPedAnimation. If you want to see what the player ped is doing as you control them that is getPedTask.
addEventHandler("onClientPreRender",root, function () local block, animation = getPedAnimation(localPlayer) dxDrawText ( "CURRENT ANIMATION INFO...", 100, 300 ) if not block then block = "N/A" end if not animation then animation = "N/A" end dxDrawText ( "Block = "..block.." Animation = "..animation, 100, 315 ) end )
See Also
- canPedBeKnockedOffBike
- getPedAnalogControlState
- getPedAnimation
- getPedBonePosition
- getPedCameraRotation
- getPedControlState
- getPedMoveState
- getPedOxygenLevel
- getPedSimplestTask
- getPedTargetCollision
- getPedTargetEnd
- getPedTargetStart
- getPedTask
- getPedVoice
- getPedWeaponMuzzlePosition
- givePedWeapon
- isPedBleeding
- isPedDoingTask
- isPedReloadingWeapon
- isPedTargetingMarkerEnabled
- setAnalogControlState
- setPedAimTarget
- setPedAnalogControlState
- setPedBleeding
- setPedCameraRotation
- setPedCanBeKnockedOffBike
- setPedControlState
- setPedEnterVehicle
- setPedExitVehicle
- IsPedFootBloodEnabled
- setPedFootBloodEnabled
- setPedLookAt
- setPedOxygenLevel
- setPedTargetingMarkerEnabled
- setPedVoice
- Shared
- addPedClothes
- getPedClothes
- removePedClothes
- createPed
- getPedAmmoInClip
- getPedArmor
- getPedFightingStyle
- getPedOccupiedVehicle
- getPedOccupiedVehicleSeat
- getPedStat
- getPedTarget
- getPedTotalAmmo
- getPedWalkingStyle
- getPedWeapon
- getPedWeaponSlot
- getPedContactElement
- getValidPedModels
- isPedChoking
- isPedDead
- isPedDoingGangDriveby
- isPedDucked
- isPedHeadless
- isPedInVehicle
- isPedOnFire
- isPedOnGround
- isPedWearingJetpack
- killPed
- removePedFromVehicle
- setPedAnimation
- setPedAnimationProgress
- setPedAnimationSpeed
- setPedArmor
- setPedDoingGangDriveby
- setPedFightingStyle
- setPedHeadless
- setPedOnFire
- setPedStat
- setPedWalkingStyle
- setPedWeaponSlot
- warpPedIntoVehicle