Skip to main content

Rytrak instalation

r_handcuffs has to be edited before using sf-trunks. Without it animations will be bugged.

Remember! Create a backup before editing files of your existing resources!

r_handcuffs

You have to add this code at the end of client/cl_utils.lua file.

local isInTrunk = false
local oldTaskAnim = TaskPlayAnim

TaskPlayAnim = function(ped, animDictionary, animationName, blendInSpeed, blendOutSpeed, duration, flag, playbackRate, lockX, lockY, lockZ)
    if not isInTrunk then
        oldTaskAnim(ped, animDictionary, animationName, blendInSpeed, blendOutSpeed, duration, flag, playbackRate, lockX, lockY, lockZ)
    end
end

local oldTaskAnimAdv = TaskPlayAnimAdvanced
TaskPlayAnimAdvanced = function(ped, animDict, animName, posX, posY, posZ, rotX, rotY, rotZ, animEnterSpeed, animExitSpeed, duration, flag, animTime, p14, p15)
    if not isInTrunk then
        oldTaskAnimAdv(ped, animDict, animName, posX, posY, posZ, rotX, rotY, rotZ, animEnterSpeed, animExitSpeed, duration, flag, animTime, p14, p15)
    end
end

AddEventHandler("sf-trunks:isUsingCamera", function(state)
    isInTrunk = state
end)

local function triggerChange()
    Wait(0)
    local isCuffed = LocalPlayer.state[Config.StatebagsName.handcuffs]
    local isRope = LocalPlayer.state[Config.StatebagsName.rope]

    if isCuffed or isRope then
        LocalPlayer.state:set("SFTRUNKS_HANDCUFFED", true, true)
    else
        LocalPlayer.state:set("SFTRUNKS_HANDCUFFED", false, true)
    end
end

AddStateBagChangeHandler(Config.StatebagsName.handcuffs, ("player:%s"):format(GetPlayerServerId(PlayerId())), function(bagName, key, value, reserved, replicated)
    triggerChange()
end)

AddStateBagChangeHandler(Config.StatebagsName.rope, ("player:%s"):format(GetPlayerServerId(PlayerId())), function(bagName, key, value, reserved, replicated)
    triggerChange()
end)

Remember to restart r_handcuffs after that.