Hand-held radio emote

Hand-held radio emote :radio:

I added hand-held radio animation on my roleplay server and I have seen people asking this, so I decided to share the code

Requirements pma-voice, RPEmotes, Also you need radio script ex. ac_radio
Video preview Video


INSTALLATION
pma-voice/client/module/radio.lua
Line: 185 - 237 #Can be different depends version and if you have made some changes
RegisterCommand('+radiotalk', function()
	if GetConvarInt('voice_enableRadios', 1) ~= 1 then return end
	if isDead() then return end
	if not isRadioEnabled() then return end
	if not radioPressed then
		if radioChannel > 0 then
			logger.info('[radio] Start broadcasting, update targets and notify server.')
			addVoiceTargets(radioData, callData)
			TriggerServerEvent('pma-voice:setTalkingOnRadio', true)
			radioPressed = true
			local shouldPlayAnimation = isRadioAnimEnabled()
			playMicClicks(true)
			if shouldPlayAnimation then
				RequestAnimDict('anim@male@holding_radio')
			end
			CreateThread(function()
				TriggerEvent("pma-voice:radioActive", true)
				LocalPlayer.state:set("radioActive", true, true);
				local checkFailed = false
				while radioPressed do
					if radioChannel < 0 or isDead() or not isRadioEnabled() then
						checkFailed = true
						break
					end
					if shouldPlayAnimation and HasAnimDictLoaded("anim@male@holding_radio") then
						if not IsEntityPlayingAnim(PlayerPedId(), "anim@male@holding_radio", "holding_radio_clip", 3) then
							TaskPlayAnim(PlayerPedId(), "anim@male@holding_radio", "holding_radio_clip", 8.0, 2.0, -1, 50, 2.0, false,
								false,
							false)
							radioProp = CreateObject(`prop_cs_hand_radio`, 1.0, 1.0, 1.0, 1, 1, 0)
							AttachEntityToEntity(radioProp, PlayerPedId(), GetPedBoneIndex(PlayerPedId(), 28422), 0.0750, 0.0230, -0.0230, -90.0000, 0.0, -59.9999, 1, 0, 0, 0, 2, 1)
						end
					end
					SetControlNormal(0, 249, 1.0)
					SetControlNormal(1, 249, 1.0)
					SetControlNormal(2, 249, 1.0)
					Wait(0)
				end


				if checkFailed then
					logger.info("Canceling radio talking as the checks have failed.")
					ExecuteCommand("-radiotalk")
				end
				if shouldPlayAnimation then
					RemoveAnimDict('anim@male@holding_radio')
				end
			end)
		else
			logger.info("Player tried to talk but was not on a radio channel")
		end
	end
end, false)

pma-voice/client/module/radio.lua
Line: 239- 253 #Can be different depends version and if you have made some changes

RegisterCommand('-radiotalk', function()
	if radioChannel > 0 and radioPressed then
		radioPressed = false
		MumbleClearVoiceTargetPlayers(voiceTarget)
		addVoiceTargets(callData)
		TriggerEvent("pma-voice:radioActive", false)
		LocalPlayer.state:set("radioActive", false, true);
		playMicClicks(false)
		if GetConvarInt('voice_enableRadioAnim', 1) == 1 then
			StopAnimTask(PlayerPedId(), "anim@male@holding_radio", "holding_radio_clip", -4.0)
			DeleteObject(radioProp)
		end
		TriggerServerEvent('pma-voice:setTalkingOnRadio', false)
	end
end, false)
7 Likes

Hii, I get this error

Hi, you can also try just replace animations

Line: 197-200

if shouldPlayAnimation then
				RequestAnimDict('random@arrests')
			end

with:

if shouldPlayAnimation then
				RequestAnimDict('anim@male@holding_radio')
			end

Line: 209 -215

if shouldPlayAnimation and HasAnimDictLoaded("random@arrests") then
						if not IsEntityPlayingAnim(PlayerPedId(), "random@arrests", "generic_radio_enter", 3) then
							TaskPlayAnim(PlayerPedId(), "random@arrests", "generic_radio_enter", 8.0, 2.0, -1, 50, 2.0, false,
								false,
							false)
						end
					end

With

					if shouldPlayAnimation and HasAnimDictLoaded("anim@male@holding_radio") then
						if not IsEntityPlayingAnim(PlayerPedId(), "anim@male@holding_radio", "holding_radio_clip", 3) then
							TaskPlayAnim(PlayerPedId(), "anim@male@holding_radio", "holding_radio_clip", 8.0, 2.0, -1, 50, 2.0, false,
								false,
							false)
							radioProp = CreateObject(`prop_cs_hand_radio`, 1.0, 1.0, 1.0, 1, 1, 0)
							AttachEntityToEntity(radioProp, PlayerPedId(), GetPedBoneIndex(PlayerPedId(), 28422), 0.0750, 0.0230, -0.0230, -90.0000, 0.0, -59.9999, 1, 0, 0, 0, 2, 1)
						end
					end

Line 229-231

				if shouldPlayAnimation then
					RemoveAnimDict('random@arrests')
				end

with

				if shouldPlayAnimation then
					RemoveAnimDict('anim@male@holding_radio')
				end

and line 245-247

		if GetConvarInt('voice_enableRadioAnim', 1) == 1 then
			StopAnimTask(PlayerPedId(), "random@arrests", "generic_radio_enter", -4.0)
		end

with

		if GetConvarInt('voice_enableRadioAnim', 1) == 1 then
			StopAnimTask(PlayerPedId(), "anim@male@holding_radio", "holding_radio_clip", -4.0)
			DeleteObject(radioProp)
		end
3 Likes

Nice jobs mans!

1 Like

help

can’t make this my PMA is different in the radio.lua i have only 213 line

update it ?

Use all updated versions?

Thank you very much for sharing the code, I didn’t think of it. But now to a problem where you might hate an idea if you radio and walk through a door the prop gets stuck, you might be able to help with a prop fix. I’ve already tried something but haven’t gotten anything good yet

It’s the last update

GitHub - AvarianKnight/pma-voice: An easy drag n' drop resource that gives you a wrapper to use FiveM's built-in mumble voice. :slight_smile:

Yes it’s my version

How do I install it I dont get it radio.lua doesn’t even go up to 185

never mind i got it im dumb

Does it work for you? If not, I can help you :wink:

Yes I want to because I understand what is happening but I have the impression that I don’t have the same code at all

Ok, I dont know why but now it’s working thanks for all

what phone you use?

i don’t know if you asked from me, but we are using quasarphone

Sorry, I asked @Jim_2578 because I’m using an execute-for-propfix command (I thought I was in the DM sorry)