From cc1663b99bc2e771777f8678d6bee2a6da3ed1ce Mon Sep 17 00:00:00 2001 From: Avarian Knight Date: Fri, 3 Dec 2021 22:23:37 -0600 Subject: [PATCH] fix(proximity): refresh voice targets every 200ms - doesn't try to handle removing, clears voice targets instead - could lead to regression, no voice issues with me and cl2 --- client/init/proximity.lua | 17 +++-------------- 1 file changed, 3 insertions(+), 14 deletions(-) diff --git a/client/init/proximity.lua b/client/init/proximity.lua index 2f2a82a..56fe7e8 100644 --- a/client/init/proximity.lua +++ b/client/init/proximity.lua @@ -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] @@ -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:: @@ -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