[HELP] Simple animation hotkey

Hey guys,

So I am pretty new to development and I am looking for some help with a simple script. With the help of the How to create a basic script from Scammer ([How-To] Create a basic script), I have been able to begin customizing and creating my very own scripts. Currently, I am having some issues creating a hotkey for an animation. Due to my extremely basic understanding of lua, I aim to use other scripts (that give the permission to do so) as templates. Specifically here, I am using the fingerpoint script from @Geekness (How to Add Finger Pointing?) in order to create a hotkey for a military salute. I simply can’t seem to get it working and I have a couple ideas why, but after continuous trial and error, I was hoping someone could point me in the right direction!

Please keep in mind that as I am an amateur when it comes to scripting, it probably looks very sloppy, but I am only looking to improve so whatever help will be taken :slight_smile:

Here is what I have so far:

local [email protected] = false
local keyPressed = false

local function startSalute()
local ped = GetPlayerPed(-1)
RequestAnimDict(β€œ[email protected][email protected]”)
while not HasAnimDictLoaded(β€œ[email protected][email protected]”) do
Wait(0)
end
SetPedCurrentWeaponVisible(ped, 0, 1, 1, 1)
SetPedConfigFlag(ped, 36, 1)
Citizen.InvokeNative(0x2D537BA194896636, ped, β€œsalute”, 0.5, 0, β€œ[email protected][email protected]”, 24)
RemoveAnimDict(β€œ[email protected][email protected]”)
end

local function stopSalute()
local ped = GetPlayerPed(-1)
Citizen.InvokeNative(0xD01015C7316AE176, ped, β€œStop”)
if not IsPedInjured(ped) then
ClearPedSecondaryTask(ped)
end
if not IsPedInAnyVehicle(ped, 1) then
SetPedCurrentWeaponVisible(ped, 1, 1, 1, 1)
end
SetPedConfigFlag(ped, 36, 0)
ClearPedSecondaryTask(PlayerPedId())
end

local once = true
local oldval = false
local oldvalped = false

Citizen.CreateThread(function()
while true do
Wait(0)

    if once then
        once = false
    end

    if not keyPressed then
        if IsControlPressed(0, 20) and not [email protected] and IsPedOnFoot(PlayerPedId()) then
            Wait(100)
            if IsControlPressed(0, 20) then
                keyPressed = true
                startSalute()
                [email protected] = true
            else
                keyPressed = true
                while IsControlPressed(0, 20) do
                    Wait(50)
                end
            end
        elseif (IsControlPressed(0, 20) and [email protected]) or (not IsPedOnFoot(PlayerPedId()) and [email protected]) then
            keyPressed = false
            [email protected] = false
            stopSalute()
        end
    end

    if keyPressed then
        if not IsControlPressed(0, 20) then
            keyPressed = false
        end
    end
    if Citizen.InvokeNative(0x921CE12C489C4C41, PlayerPedId()) and not [email protected] then
        stopSalute()
    end
    if Citizen.InvokeNative(0x921CE12C489C4C41, PlayerPedId()) then
        if not IsPedOnFoot(PlayerPedId()) then
            stopSalute()
        end
    end
end

end)

1 Like