Animation Client
Animation is a powerfull module to play animations in your script.
JO Variables
jo.animation.easeIn
Type : float:
A variable to set the ease in speed of animations
Default: 4.0
jo.animation.easeOut
Type : float
A variable to set the ease out speed of animations
Default: -4.0
JO Functions
jo.animation.faceEntity()
Turn the ped to face the target
Syntax
jo.animation.faceEntity(ped, target, waiter)Parameters
ped : integer
The ped to turn
target : integer
The target to face
waiter : boolean Optional
If need to reach the heading to end the function - default:true
Example
local ped = PlayerPedId()
local targetSource = 5
local targetEntity = GetPlayerPed(GetPlayerFromServerId(targetSource))
local waiter = true
jo.animation.faceEntity(ped, targetSource, targetEntity, waiter)jo.animation.goToCoords()
Function to move a ped to a destination
Syntax
jo.animation.goToCoords(ped, coords, speed, waiter, distanceToStop)Parameters
ped : integer
The ped to move
coords : vector
vec3 or vec4 - The coordinate of the destination
If vector4 is used, the ped will stop at the end and turn to the desired heading
speed : number Optional
The speed of the walk - default:1.0
waiter : boolean Optional
If need to wait the reach of location to end the function - default:false
distanceToStop : number Optional
The distance between the ped and the destination to stop it - default:0.0
Example
local ped = PlayerPedId()
local destination = vec4(1324.0, 234.0, 50.0, 180.0)
local speed = 2.0
local waiter = true
local distanceToStop = 3.0
jo.animation.goToCoords(ped, destination, speed, waiter, distanceToStop)jo.animation.load()
Load the dictionnary of animation
Syntax
jo.animation.load(dict, waiter)Parameters
dict : string
The dictionnary of the animation
waiter : boolean Optional
If need to wait the loading to end the function - default:false
Example
local dict = "cnv_camp@rchso@cnv@ccdtc33@player_karen"
local waiter = true
jo.animation.load(dict, waiter)jo.animation.play()
Play animation. The function load automatically necessary resources.
Flags list
| Bit index | Integer value | Name | Description |
|---|---|---|---|
| 0 | 1 | AF_LOOPING | Loop the animation continuously |
| 1 | 2 | AF_HOLD_LAST_FRAME | Freeze on the last frame when done |
| 2 | 4 | AF_NOT_INTERRUPTABLE | Prevent other tasks from cancelling the animation |
| 3 | 8 | AF_UPPERBODY | Play on upper body only (allows movement) |
| 4 | 16 | AF_SECONDARY | Play as a secondary/blended animation |
| 5 | 32 | AF_ABORT_ON_PED_MOVEMENT | Stop the animation when the ped moves |
| 6 | 64 | AF_ADDITIVE | Blend additively on top of existing animations |
| 7 | 128 | AF_OVERRIDE_PHYSICS | Override physics during playback |
| 8 | 256 | AF_EXTRACT_INITIAL_OFFSET | Use the animation's initial position offset |
| 9 | 512 | AF_EXIT_AFTER_INTERRUPTED | Exit cleanly when interrupted |
| 10 | 1024 | AF_TAG_SYNC_IN | Sync entry tag with other peds |
| 11 | 2048 | AF_TAG_SYNC_OUT | Sync exit tag with other peds |
| 12 | 4096 | AF_TAG_SYNC_CONTINUOUS | Continuously sync tag with other peds |
| 13 | 8192 | AF_FORCE_START | Force the animation to start immediately |
| 14 | 16384 | AF_USE_KINEMATIC_PHYSICS | Use kinematic physics during playback |
| 15 | 32768 | AF_USE_MOVER_EXTRACTION | Extract movement from the animation clip |
| 16 | 65536 | AF_DONT_SUPPRESS_LOCO | Don't suppress locomotion during playback |
| 17 | 131072 | AF_ENDS_IN_DEAD_POSE | Hold the final dead pose at the end |
| 18 | 262144 | AF_ACTIVATE_RAGDOLL_ON_COLLISION | Trigger ragdoll on collision |
| 19 | 524288 | AF_DONT_EXIT_ON_DEATH | Keep playing the animation after death |
| 20 | 1048576 | AF_ABORT_ON_WEAPON_DAMAGE | Cancel the animation when the ped takes weapon damage |
| 21 | 2097152 | AF_DISABLE_FORCED_PHYSICS_UPDATE | Disable forced physics updates during playback |
| 22 | 4194304 | AF_GESTURE | Play as a gesture (short, non-blocking) |
| 23 | 8388608 | AF_SKIP_IF_BLOCKED_BY_HIGHER_PRIORITY_TASK | Skip if a higher-priority task is active |
| 24 | 16777216 | AF_USE_ABSOLUTE_MOVER | Use absolute world-space movement extraction |
| 25 | 33554432 | AF_0xC57F16E7 | Unknown |
| 26 | 67108864 | AF_UPPERBODY_TAGS | Apply upper body sync tags |
| 27 | 134217728 | AF_PROCESS_ATTACHMENTS_ON_START | Process ped attachments at animation start |
| 28 | 268435456 | AF_EXPAND_PED_CAPSULE_FROM_SKELETON | Expand the ped's collision capsule based on skeleton |
| 29 | 536870912 | AF_BLENDOUT_WRT_LAST_FRAME | Blend out relative to the last frame position |
| 30 | 1073741824 | AF_DISABLE_PHYSICAL_ACTIVATION | Disable physical activation events |
| 31 | 2147483648 | AF_DISABLE_RELEASE_EVENTS | Disable release/end events for the animation |
Syntax
jo.animation.play(ped, dict, name, duration, flag, offset)Parameters
ped : integer
The entity where the animation will be played
dict : string
The dictionnary of the animation
name : string
The name of the animation
duration : integer Optional
Duration of the animation in ms - default:-1
flag : integer|table Optional
Animation flags - default:0. Pass an integer value or a table of bit indices (e.g.
offset : number Optional
The offset of the animation 0.0 <> 1.0 - default: 0.0
Return Value
Type : number
Example
local ped = PlayerPedId()
local dict = "cnv_camp@rchso@cnv@ccdtc33@player_karen"
local name = "arthur_dance_loop"
local duration = -1
local flag = 1
jo.animation.play(ped, dict, name, duration, flag)jo.animation.setDesiredHeading()
Turn the ped to the desired heading
Syntax
jo.animation.setDesiredHeading(ped, heading, waiter)Parameters
ped : integer
The ped to turn
heading : number
The desired heading
waiter : boolean Optional
If need to reach the heading to end the function - default:true
Example
local ped = PlayerPedId()
local heading = 180.0
local waiter = true
jo.animation.setDesiredHeading(ped, heading, waiter)jo.animation.waitTaskEnd()
Syntax
jo.animation.waitTaskEnd(ped, task)Example
local ped = PlayerPedId()
local coordinates = vec3(1324.0, 234.0, 50.0)
local speed = 1.0
local maxTime = -1
local radiusEnd = 2.0
local flags = 2 -- Slide at end
local finalHeading = 180.0
TaskFollowNavMeshToCoord(ped, coordinates, speed, maxTime, radiusEnd, flags, finalHeading)
local task = `SCRIPT_TASK_FOLLOW_NAV_MESH_TO_COORD`
jo.animation.waitTaskEnd(ped, task)
print('Task ended. Player reached the coordinates')