Skip to content

tw.animation

Side: Client

Animation dictionary loading and playback utilities.

Constants

ConstantValueDescription
tw.animation.easeIn4.0Ease-in blend speed
tw.animation.easeOut-4.0Ease-out blend speed

Functions

tw.animation.load(dict, waiter?)

Loads an animation dictionary into memory.

ParameterTypeDefaultDescription
dictstringAnimation dictionary name
waiterboolean?falseIf true, blocks until the dictionary is fully loaded

tw.animation.play(ped, dict, name, duration?, flag?, offset?)

Plays an animation on a ped. Automatically loads the dictionary if not already loaded.

ParameterTypeDefaultDescription
pedintegerPed entity handle
dictstringAnimation dictionary name
namestringAnimation clip name
durationinteger?-1Duration in ms (-1 = full animation length)
flaginteger?0Animation flags
offsetnumber?0.0Start offset (0.0 to 1.0)

Returns: number — Duration of the animation in milliseconds.

Examples

Play an animation

lua
local ped = PlayerPedId()
local duration = tw.animation.play(ped, "amb_work@world_human_sweeping@base", "base", 5000)

Wait(duration)
ClearPedTasks(ped)

Pre-load a dictionary

lua
-- Load in advance (blocking)
tw.animation.load("mini_games@story@beechers@john_quests@finger_filet@table_a", true)

-- Play later without loading delay
tw.animation.play(ped, "mini_games@story@beechers@john_quests@finger_filet@table_a", "round_1_idle", -1, 1)

Using ease constants with flags

lua
-- Play with looping flag (flag 1)
tw.animation.play(ped, "amb_work@world_human_sweeping@base", "base", -1, 1)

Notes

  • play() auto-loads the dictionary, so you do not need to call load() first unless you want to pre-cache.
  • When duration is -1, the animation plays for its full natural length.
  • Common flags: 0 = normal, 1 = looping, 32 = upper body only, 48 = upper body looping.

Premium RedM Scripts — Multi-Framework