Skip to content

Commit

Permalink
fix(proximity): refresh voice targets every 200ms
Browse files Browse the repository at this point in the history
- doesn't try to handle removing, clears voice targets instead
- could lead to regression, no voice issues with me and cl2
  • Loading branch information
AvarianKnight committed Dec 4, 2021
1 parent c443f8d commit cc1663b
Showing 1 changed file with 3 additions and 14 deletions.
17 changes: 3 additions & 14 deletions client/init/proximity.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
local disableUpdates = false
local isListenerEnabled = false

local currentVoiceTargets = {}

function addNearbyPlayers()
if disableUpdates then return end
local coords = GetEntityCoords(PlayerPedId())
local voiceModeData = Cfg.voiceModes[mode]
local distance = GetConvar('voice_useNativeAudio', 'false') == 'true' and voiceModeData[1] * 3 or voiceModeData[1]

MumbleClearVoiceTargetChannels(voiceTarget)
local players = GetActivePlayers()
for i = 1, #players do
local ply = players[i]
Expand All @@ -17,18 +17,11 @@ function addNearbyPlayers()
if serverId == playerServerId then goto skip_loop end

local ped = GetPlayerPed(ply)
local isTarget = currentVoiceTargets[serverId]
if #(coords - GetEntityCoords(ped)) < distance then
local voiceChannel = MumbleGetVoiceChannelFromServerId(serverId)
if isTarget then goto skip_loop end

logger.info('Added %s as a voice target', serverId)
logger.verbose('Added %s as a voice target', serverId)
MumbleAddVoiceTargetChannel(voiceTarget, serverId)
currentVoiceTargets[serverId] = true
elseif isTarget then
logger.info('Removed %s from voice targets', serverId)
MumbleRemoveVoiceTargetChannel(voiceTarget, serverId)
currentVoiceTargets[serverId] = nil
end

::skip_loop::
Expand Down Expand Up @@ -72,10 +65,6 @@ RegisterNetEvent('onPlayerDropped', function(serverId)
MumbleRemoveVoiceChannelListen(serverId)
logger.verbose("Removing %s from listen table", serverId)
end
if currentVoiceTargets[serverId] then
currentVoiceTargets[serverId] = nil
MumbleRemoveVoiceChannelListen(serverId)
end
end)

-- cache talking status so we only send a nui message when its not the same as what it was before
Expand Down

2 comments on commit cc1663b

@t3chman
Copy link

@t3chman t3chman commented on cc1663b Dec 5, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FYI, I have a report that this is working without issue so far in a live server and it may even solve some of the previous issues they were having, at least with RedM Mumble (either that or a couple missing convars now set) :)

@jaffamies
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

been testing this for few days and can 100% confirm it fixed the issue "Can't hear people sometimes"

Please sign in to comment.