Playing animations

The code responsible for playing animations is the following :

RegisterCommand('kinetix_anim', function(source, params)
    local dictName = params[1] .. '@animation'
    local animName = 'clip'
    local retry = 0

    if not HasAnimDictLoaded(dictName) then
       RequestAnimDict(dictName)
    end

    while not HasAnimDictLoaded(dictName) and retry < 50 do
        Wait(0)
       retry = retry + 1
    end
    retry = 0
    ClearPedTasks(PlayerPedId())
    local animFlag = IsPedInAnyVehicle(PlayerPedId()) == 1 and 16 + 32 or 0
    if IsPedOnAnyBike(PlayerPedId()) then return end
    TaskPlayAnim(PlayerPedId(), dictName, animName, 8.0, -8.0, -1, animFlag, 0.0, false, false, false)
end)

A specific command with the emote uuid as a parameter needs to be called in order to play animations. This is the command used by the emote wheel.

The command will check that the anim dict has been loaded. The emote_ready event will also load anim dicts, in order for the client to have every custom animations preloaded to ensure network synchronization. The anim dict must not be unloaded after playing. This method will use animation flags to control animations. In the case the user is in a vehicle, flags 16 and 32 will be used to only animate upper body and void clipping through the vehicle. In the case the user is on a bike, the playing is disabled.

Last updated