Skip to content

Commit bc34023

Browse files
committed
fix(main/targets): fix clearing targets when its no longer needed
- only need to clear targeting on the end of the broadcast - don't set radio/call channels on removal, its already set elsewhere (whoops), fixes race condition with net events changing the channel
1 parent 87e390e commit bc34023

File tree

3 files changed

+6
-11
lines changed

3 files changed

+6
-11
lines changed

client/main.lua

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -76,18 +76,15 @@ end
7676
---@param targets table expects multiple tables to be sent over
7777
function playerTargets(...)
7878
local targets = {...}
79-
local addedPlayers = {}
80-
81-
MumbleClearVoiceTarget(1)
82-
MumbleClearVoiceTargetPlayers(1)
83-
MumbleSetVoiceTarget(0)
84-
MumbleSetVoiceTarget(1)
85-
currentGrid = 0
79+
local addedPlayers = {
80+
[playerServerId] = true
81+
}
8682

8783
for i = 1, #targets do
8884
for id, _ in pairs(targets[i]) do
89-
if id == playerServerId or addedPlayers[id] then
90-
debug.verbose(('[main] %s is already target (or self) don\'t re-add'):format(id))
85+
-- we don't want to log ourself, or listen to ourself
86+
if addedPlayers[id] and id ~= playerServerId then
87+
debug.verbose(('[main] %s is already target don\'t re-add'):format(id))
9188
goto skip_loop
9289
end
9390
if not addedPlayers[id] then

client/module/phone.lua

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ RegisterNetEvent('pma-voice:removePlayerFromCall', function(plySource)
4646
toggleVoice(tgt, false, 'phone')
4747
end
4848
end
49-
callChannel = 0
5049
callData = {}
5150
playerTargets(radioPressed and radioData or {}, callData)
5251
else

client/module/radio.lua

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@ function removePlayerFromRadio(plySource)
5454
end
5555
end
5656
radioData = {}
57-
radioChannel = 0
5857
playerTargets({}, NetworkIsPlayerTalking(PlayerId()) and callData or {})
5958
else
6059
radioData[plySource] = nil

0 commit comments

Comments
 (0)