PlayAnim
Load an anim dictionary and play an animation on a ped in one line, no boilerplate.
Load an anim dictionary and play an animation on a ped in one line, no boilerplate.
lib.playAnim(ped, dict, anim, props?) loads an anim dictionary and plays the animation on a ped in
one line — no more RequestAnimDict + while not HasAnimDictLoaded + TaskPlayAnim boilerplate.
local ped = PlayerPedId()
lib.playAnim(ped, 'amb@world_human_smoking@male@male_a@base', 'base')pednumberrequiredThe ped handle.
dictstringrequiredAnimation dictionary, e.g. amb@world_human_smoking@male@male_a@base.
animstringrequiredAnimation name inside the dict, e.g. base.
propstableoptionalOptional overrides — see below.
props field | Type | Default | Description |
|---|---|---|---|
flag | number | 0 | Animation flag (1 loop, 49 upper-body loop…). |
duration | number | -1 | Duration in ms (-1 plays to the natural end). |
blendIn | number | 8.0 | Blend-in speed. |
blendOut | number | -8.0 | Blend-out speed (negative is intentional — GTA convention). |
props fieldflagnumber01 loop, 49 upper-body loop…).props fielddurationnumber-1-1 plays to the natural end).props fieldblendInnumber8.0props fieldblendOutnumber-8.0lib.playAnim(ped, 'mp_player_intdrink', 'loop_bottle', {
flag = 49,
duration = 3000,
blendIn = 4.0,
})This blocks the current thread: loading the dict waits until it's ready, which can take a few
frames if it isn't cached — don't call it from a critical thread or a NUI callback. It does not free
the dict afterwards (RemoveAnimDict is never called), so release it yourself for one-shot anims.
duration = -1 plays to the end, but combined with a loop flag (1) it loops forever.