Double animation for PMA-VOICE

Double animation for PMA-VOICE

Code is accessible Yes
Subscription-based No
Support Yes

Hello, I’ve been looking for a script to use a dual animation for pma-voice for a long time, and I decided to modify it myself.
Here I’ll show you how to add a command to switch between animations.

Go to client/module/radio.lua and add this line at the beginning of the code:

local currentRadioAnim = 'default'

Then, add this command wherever you want:

RegisterCommand('changeradioanim', function()

    if currentRadioAnim == 'default' then
        currentRadioAnim = 'alternative'
    else
        currentRadioAnim = 'default'
    end
end)
TriggerEvent('chat:addSuggestion', '/changeradioanim', 'Switch the radio animation with this command.')

Now, replace the +radiotalk command with this other command:

RegisterCommand('+radiotalk', function()
    if GetConvarInt('voice_enableRadios', 1) ~= 1 then return end
    if isDead() then return end
    if not radioPressed and radioEnabled then
        if radioChannel > 0 then
            logger.info('[radio] Start broadcasting, update targets and notify server.')
            playerTargets(radioData, MumbleIsPlayerTalking(PlayerId()) and callData or {})
            TriggerServerEvent('pma-voice:setTalkingOnRadio', true)
            radioPressed = true
            playMicClicks(true)

            if GetConvarInt('voice_enableRadioAnim', 0) == 1 and not (GetConvarInt('voice_disableVehicleRadioAnim', 0) == 1 and IsPedInAnyVehicle(PlayerPedId(), false)) then
                if not disableRadioAnim then
                    if currentRadioAnim == 'default' then
                        RequestAnimDict('random@arrests')
                        while not HasAnimDictLoaded('random@arrests') do
                            Citizen.Wait(10)
                        end
                        TaskPlayAnim(PlayerPedId(), "random@arrests", "generic_radio_chatter", 8.0, 2.0, -1, 50, 2.0, 0, 0, 0)
                    elseif currentRadioAnim == 'alternative' then
                        RequestAnimDict('cellphone@')
                        while not HasAnimDictLoaded('cellphone@') do
                            Citizen.Wait(10)
                        end
                        TaskPlayAnim(PlayerPedId(), "cellphone@", "cellphone_call_listen_base", 8.0, 2.0, -1, 50, 2.0, 0, 0, 0)
                    end

                end
            end
            Citizen.CreateThread(function()
                TriggerEvent("pma-voice:radioActive", true)
                while radioPressed do
                    Wait(0)
                    SetControlNormal(0, 249, 1.0)
                    SetControlNormal(1, 249, 1.0)
                    SetControlNormal(2, 249, 1.0)
                end
            end)
        end
    end
end, false)

Finally, replace the +radiotalk command with:

RegisterCommand('-radiotalk', function()
    if radioChannel > 0 or radioEnabled and radioPressed then
        radioPressed = false
        MumbleClearVoiceTargetPlayers(voiceTarget)
        playerTargets(MumbleIsPlayerTalking(PlayerId()) and callData or {})
        TriggerEvent("pma-voice:radioActive", false)
        playMicClicks(false)
        if GetConvarInt('voice_enableRadioAnim', 0) == 1 then
            if currentRadioAnim == 'default' then
                StopAnimTask(PlayerPedId(), "random@arrests", "generic_radio_chatter", -4.0)
            elseif currentRadioAnim == 'alternative' then
                StopAnimTask(PlayerPedId(), "cellphone@", "cellphone_call_listen_base", -4.0)
            end
        end
        TriggerServerEvent('pma-voice:setTalkingOnRadio', false)
    end
end, false)

Now, when you are connected to a radio and use the /changeradio command, the animation will switch from the arm to the phone, and vice versa.

Github: https://github.com/nebula0366
Download (Github): pma-voice
Direct Download Link:
pma-voice.zip (383.2 KB)

3 Likes

Sorry op i dont get it what is the animation what is changing do you have video or any ?

1 Like

yeah, i will do it tommorrow

1 Like

im sorry is great script but i dont get it .