Player::taskPlayAnim: Difference between revisions

From RAGE Multiplayer Wiki
No edit summary
(Tidied up formatting, updated information based on testing. Removed misinformation.)
Line 3: Line 3:
Plays an animation on the targetted ped.
Plays an animation on the targetted ped.


CLIENTSIDE: You must always preload the dictionary (use [https://wiki.rage.mp/index.php?title=Streaming::requestAnimDict Streaming::requestAnimDict] to preload an animation), serverside will have some loaded but not all.
You must always preload the dictionary (use [https://wiki.rage.mp/index.php?title=Streaming::requestAnimDict Streaming::requestAnimDict] to preload an animation), serverside will have some loaded but not all.


==Arguments==
==Arguments==


*'''[[Animations|Animations Dictionary]]'''
'''Animation Dictionary, Animation Name'''
* A few possible values can be found on the [[Animations|Animations]] page.


'''Speed''':
'''Blend speed''':
*Normal speed is  
* Defines the blend time before/after the animation. Most common value is 8.
<pre>8.0f</pre>


'''Speed Multiplier''': Multiply the playback speed
:<pre>1 / [time in seconds] = [blend speed]</pre>


'''Duration''':  
'''Duration (ms)''':  
*-1 (Default)
* How long the animation plays. -1 can be used to play the whole animation (or loop indefinitely, if flag 1 is used)
* 0 (No Animation at all)
* Small value (Slows the animation)
* Other values (Freezes  the player till ms was passed) (No effect if flag is set to be controllable.)


'''Animation Flags ''':  
'''Animation Flags ''':  
*NORMAL = 0,
*0: Normal
*REPEAT = 1,
*1: Repeat/loop
*STOP_LAST_FRAME = 2,
*2: Stop animation on last frame
*UPPERBODY = 16,
*16: Animate upper body only
*ENABLE_PLAYER_CONTROL = 32,
*32: Enable player control (animation is played as a secondary task - can be used to mix animations)
*CANCELABLE = 128,
*128: Cancellable
*ADDITIVE = 256,
*256: Additive animation
*512: Disables collision and physics on ped
*1024: Disables collision and physics on ped, applies animation initial offset (see [[Ped::getAnimInitialOffsetPosition]] and [[Ped::getAnimInitialOffsetRotation]])
*2048: Disables collision and physics on ped


*Odd number : loop infinitely
:''Note:'' You can sum flags together. For example, if you want an upper body controllable animation with last frame you can do 48+2 which is flag 50.
*Even number : Freeze at last frame
*Multiple of 4: Freeze at last frame but controllable
*01 to 15 : Full body
*10 to 31 : Upper body
*32 to 47 : Full body > Controllable
*48 to 63 : Upper body > Controllable
*001 to 255 : Normal
*256 to 511 : Additive


'''Note:'''
'''Start Offset''':
* You can sum flags together to works for example if you want an upper body controllable animation with last frame you just do 48+2 which is flag 50
*Can be used to skip a part of the animation. Values are between 0.0 and 1.0
 
 
'''PlaybackRate''':
 
*values are between 0.0 and 1.0


==Syntax==
==Syntax==
<pre>player.taskPlayAnim(animDictionary, animationName, blendInSpeed, blendOutSpeed, duration, flag, playbackRate, lockX, lockY, lockZ);</pre>
<pre>player.taskPlayAnim(animDictionary, animationName, blendInSpeed, blendOutSpeed, duration, flag, startOffset, lockX, lockY, lockZ);</pre>
=== Required Arguments ===
=== Required Arguments ===
*'''animDictionary:''' String
*'''animDictionary:''' String
Line 57: Line 44:
*'''duration:''' int
*'''duration:''' int
*'''flag:''' int
*'''flag:''' int
*'''playbackRate:''' float
*'''startOffset:''' float
*'''lockX:''' Boolean
*'''lockX:''' Boolean
*'''lockY:''' Boolean
*'''lockY:''' Boolean

Revision as of 12:17, 10 October 2020

Plays an animation on the targetted ped.

You must always preload the dictionary (use Streaming::requestAnimDict to preload an animation), serverside will have some loaded but not all.

Arguments

Animation Dictionary, Animation Name

  • A few possible values can be found on the Animations page.

Blend speed:

  • Defines the blend time before/after the animation. Most common value is 8.
1 / [time in seconds] = [blend speed]

Duration (ms):

  • How long the animation plays. -1 can be used to play the whole animation (or loop indefinitely, if flag 1 is used)

Animation Flags :

  • 0: Normal
  • 1: Repeat/loop
  • 2: Stop animation on last frame
  • 16: Animate upper body only
  • 32: Enable player control (animation is played as a secondary task - can be used to mix animations)
  • 128: Cancellable
  • 256: Additive animation
  • 512: Disables collision and physics on ped
  • 1024: Disables collision and physics on ped, applies animation initial offset (see Ped::getAnimInitialOffsetPosition and Ped::getAnimInitialOffsetRotation)
  • 2048: Disables collision and physics on ped
Note: You can sum flags together. For example, if you want an upper body controllable animation with last frame you can do 48+2 which is flag 50.

Start Offset:

  • Can be used to skip a part of the animation. Values are between 0.0 and 1.0

Syntax

player.taskPlayAnim(animDictionary, animationName, blendInSpeed, blendOutSpeed, duration, flag, startOffset, lockX, lockY, lockZ);

Required Arguments

  • animDictionary: String
  • animationName: String
  • blendInSpeed: float
  • blendOutSpeed: float
  • duration: int
  • flag: int
  • startOffset: float
  • lockX: Boolean
  • lockY: Boolean
  • lockZ: Boolean

Return value

  • Undefined

Example

The example below preloads an animation and applies it into the local player.

mp.game.streaming.requestAnimDict("random@shop_robbery");//preload the animation
mp.players.local.taskPlayAnim("random@shop_robbery", "robbery_action_f", 8.0, 1.0, -1, 1, 1.0, false, false, false);

See also