Skip to content

Commit

Permalink
fix: fix initialization for calls and radios
Browse files Browse the repository at this point in the history
  • Loading branch information
AvarianKnight committed Oct 2, 2023
1 parent 6042f9a commit 56a5170
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 10 deletions.
18 changes: 18 additions & 0 deletions client/init/main.lua
Original file line number Diff line number Diff line change
Expand Up @@ -304,3 +304,21 @@ if gameVersion == 'redm' then
end
end)
end


--- handles initializiation for whenever radio or call data changes
--- calls should always be last because they're assumed to always be enabled so
--- theres no delay in talking.
function handleRadioAndCallInit()
for tgt, enabled in pairs(radioData) do
if tgt ~= playerServerId then
toggleVoice(tgt, enabled, 'radio')
end
end

for tgt, enabled in pairs(callData) do
if tgt ~= playerServerId then
toggleVoice(tgt, true, 'call')
end
end
end
6 changes: 1 addition & 5 deletions client/module/phone.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,7 @@ local callChannel = 0

RegisterNetEvent('pma-voice:syncCallData', function(callTable, channel)
callData = callTable
for tgt, _ in pairs(callTable) do
if tgt ~= playerServerId then
toggleVoice(tgt, true, 'call')
end
end
handleRadioAndCallInit()
end)

RegisterNetEvent('pma-voice:addPlayerToCall', function(plySource)
Expand Down
6 changes: 1 addition & 5 deletions client/module/radio.lua
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,7 @@ function syncRadioData(radioTable, localPlyRadioName)
end

if not radioEnabled then return end
for tgt, enabled in pairs(radioTable) do
if tgt ~= playerServerId then
toggleVoice(tgt, enabled, 'radio')
end
end
handleRadioAndCallInit()
sendUIMessage({
radioChannel = radioChannel,
radioEnabled = radioEnabled
Expand Down

0 comments on commit 56a5170

Please sign in to comment.