Hand-held radio emote
I added hand-held radio animation on my roleplay server and I have seen people asking this, so I decided to share the code
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)