From c9626952a438dfa6c8ed954452b4be474f06a1a0 Mon Sep 17 00:00:00 2001 From: Fraser Watt <28698343+FrazzIe@users.noreply.github.com> Date: Wed, 2 Sep 2020 21:13:26 +0100 Subject: [PATCH 1/5] add option to use 2d audio with vehicle passengers #41 --- client.lua | 122 +++++++++++++++++++++++++++++++++++++++++++++++++++++ config.lua | 1 + 2 files changed, 123 insertions(+) diff --git a/client.lua b/client.lua index f415617..b6afb8d 100644 --- a/client.lua +++ b/client.lua @@ -9,6 +9,8 @@ local nearbySpeakerTargets = {} local resetTargets = false local playerChunk = nil local voiceTarget = 2 +local vehiclePassengers = {} +local wasPlayerInVehicle = false -- Functions function SetVoiceData(key, value, target) @@ -217,6 +219,44 @@ function CompareChannels(playerData, type, channel) return match end +function GetVehiclePassengers(vehicle) + local passengers = {} + local passengerCount = 0 + local seatCount = GetVehicleNumberOfPassengers(vehicle) + + for seat = -1, seatCount do + if not IsVehicleSeatFree(vehicle, seat) then + passengers[GetPedInVehicleSeat(vehicle, seat)] = true + passengerCount = passengerCount + 1 + end + end + + return passengerCount, passengers +end + +function MuteVehiclePassengers(playerData) + for id, exists in pairs(vehiclePassengers) do + if exists then + if playerData.radio > 0 or playerData.call > 0 then -- Only mute player if they are not in call or radio channel with client + local remotePlayerData = voiceData[id] + if remotePlayerData ~= nil then + if playerData.radio == remotePlayerData.radio then + if not remotePlayerData.radioActive then + TogglePlayerVoice(id, false) + end + elseif playerData.call ~= remotePlayerData.call then + TogglePlayerVoice(id, false) + end + else + TogglePlayerVoice(id, false) + end + else + TogglePlayerVoice(id, false) + end + end + end +end + -- Events AddEventHandler("onClientResourceStart", function(resName) -- Initialises the script, sets up voice range, voice targets and request sync with server if GetCurrentResourceName() ~= resName then @@ -853,6 +893,88 @@ Citizen.CreateThread(function() end end) +-- Set vehicle passengers to 2D voice and ignore distance checks +Citizen.CreateThread(function() + while true do + if initialised then + if mumbleConfig.use2dAudioInVehicles then + local playerPed = PlayerPedId() + local playerData = voiceData[playerServerId] + + if not playerData then + playerData = { + mode = 2, + radio = 0, + radioActive = false, + call = 0, + callSpeaker = false, + speakerTargets = {}, + } + end + + if IsPedInAnyVehicle(playerPed, false) then + local playerVehicle = GetVehiclePedIsIn(playerPed, false) + local passengerCount, passengers = GetVehiclePassengers(playerVehicle) + + if passengerCount > 1 then + local playerId = PlayerId() + local playerList = GetActivePlayers() + local targets = {} + local newPassengers = false + + for i = 1, #playerList do + local remotePlayerId = playerList[i] + if playerId ~= remotePlayerId then + local remotePlayerPed = GetPlayerPed(remotePlayerId) + if passengers[remotePlayerPed] then + local remotePlayerServerId = GetPlayerServerId(remotePlayerId) + + targets[remotePlayerServerId] = true + + if vehiclePassengers[remotePlayerServerId] then + vehiclePassengers[remotePlayerServerId] = nil + else + newPassengers = true + end + end + end + end + + MuteVehiclePassengers(playerData) + + if newPassengers then + for id, exists in pairs(targets) do + if exists then + TogglePlayerVoice(id, true) + end + end + end + + vehiclePassengers = targets + wasPlayerInVehicle = true + else + if wasPlayerInVehicle then + MuteVehiclePassengers(playerData) + vehiclePassengers = {} + wasPlayerInVehicle = false + end + end + else + if wasPlayerInVehicle then + MuteVehiclePassengers(playerData) + vehiclePassengers = {} + wasPlayerInVehicle = false + end + end + end + + Citizen.Wait(1000) + else + Citizen.Wait(0) + end + end +end) + -- Exports exports("SetRadioChannel", SetRadioChannel) exports("addPlayerToRadio", SetRadioChannel) diff --git a/config.lua b/config.lua index 5a91103..f639637 100644 --- a/config.lua +++ b/config.lua @@ -45,6 +45,7 @@ mumbleConfig = { useExternalServer = false, -- Use an external voice server (bigger servers need this), tutorial: https://forum.cfx.re/t/how-to-host-fivems-voice-chat-mumble-in-another-server/1487449?u=frazzle externalAddress = "127.0.0.1", externalPort = 30120, + use2dAudioInVehicles = true, -- Workaround for hearing vehicle passengers at high speeds } resourceName = GetCurrentResourceName() From 3ba10ca6167c64e08dba6ad3a0625d02539ce1b5 Mon Sep 17 00:00:00 2001 From: Fraser Watt <28698343+FrazzIe@users.noreply.github.com> Date: Wed, 2 Sep 2020 21:13:57 +0100 Subject: [PATCH 2/5] only mute players that aren't a vehicle passenger --- client.lua | 68 +++++++++++++++++++++++++++++++----------------------- 1 file changed, 39 insertions(+), 29 deletions(-) diff --git a/client.lua b/client.lua index b6afb8d..ebfd9d8 100644 --- a/client.lua +++ b/client.lua @@ -343,12 +343,14 @@ AddEventHandler("mumble:SetVoiceData", function(player, key, value) if CompareChannels(playerData, "radio", radioChannel) then if playerServerId ~= player then if unmutedPlayers[player] then - if playerData.call > 0 then -- Check if the client is in a call - if not CompareChannels(voiceData[player], "call", playerData.call) then -- Check if the client is in a call with the unmuted player - TogglePlayerVoice(player, false) + if not vehiclePassengers[player] then -- Mute if player is not in client vehicle + if playerData.call > 0 then -- Check if the client is in a call + if not CompareChannels(voiceData[player], "call", playerData.call) then -- Check if the client is in a call with the unmuted player + TogglePlayerVoice(player, false) + end + else + TogglePlayerVoice(player, false) -- mute player on radio channel leave end - else - TogglePlayerVoice(player, false) -- mute player on radio channel leave end end @@ -359,12 +361,12 @@ AddEventHandler("mumble:SetVoiceData", function(player, key, value) for id, _ in pairs(radioData[radioChannel]) do -- Mute players that aren't supposed to be unmuted if id ~= playerServerId then if unmutedPlayers[id] then -- Check if a player isn't muted - if playerData.call > 0 then -- Check if the client is in a call - if not CompareChannels(voiceData[id], "call", playerData.call) then -- Check if the client is in a call with the unmuted player - TogglePlayerVoice(id, false) - end - else - if unmutedPlayers[id] then + if not vehiclePassengers[id] then -- Mute if player is not in client vehicle + if playerData.call > 0 then -- Check if the client is in a call + if not CompareChannels(voiceData[id], "call", playerData.call) then -- Check if the client is in a call with the unmuted player + TogglePlayerVoice(id, false) + end + else TogglePlayerVoice(id, false) end end @@ -424,12 +426,14 @@ AddEventHandler("mumble:SetVoiceData", function(player, key, value) if CompareChannels(playerData, "call", callChannel) then if playerServerId ~= player then if unmutedPlayers[player] then - if playerData.radio > 0 then -- Check if the client is in a call - if not CompareChannels(voiceData[player], "radio", playerData.radio) then -- Check if the client is in a call with the unmuted player - TogglePlayerVoice(player, false) + if not vehiclePassengers[player] then -- Mute if player is not in client vehicle + if playerData.radio > 0 then -- Check if the client is in a call + if not CompareChannels(voiceData[player], "radio", playerData.radio) then -- Check if the client is in a call with the unmuted player + TogglePlayerVoice(player, false) + end + else + TogglePlayerVoice(player, false) -- mute player on radio channel leave end - else - TogglePlayerVoice(player, false) -- mute player on radio channel leave end end @@ -441,19 +445,21 @@ AddEventHandler("mumble:SetVoiceData", function(player, key, value) for id, _ in pairs(callData[callChannel]) do -- Mute players that aren't supposed to be unmuted if id ~= playerServerId then if unmutedPlayers[id] then -- Check if a player isn't muted - if playerData.radio > 0 then -- Check if the client is in a radio channel - if not CompareChannels(voiceData[id], "radio", playerData.radio) then -- Check if the client isn't in the radio channel with the unmuted player - TogglePlayerVoice(id, false) - else -- Client is in the same radio channel with unmuted player - if voiceData[id] ~= nil then - if not voiceData[id].radioActive then -- Check if the unmuted player isn't talking - TogglePlayerVoice(id, false) + if not vehiclePassengers[id] then -- Mute if player is not in client vehicle + if playerData.radio > 0 then -- Check if the client is in a radio channel + if not CompareChannels(voiceData[id], "radio", playerData.radio) then -- Check if the client isn't in the radio channel with the unmuted player + TogglePlayerVoice(id, false) + else -- Client is in the same radio channel with unmuted player + if voiceData[id] ~= nil then + if not voiceData[id].radioActive then -- Check if the unmuted player isn't talking + TogglePlayerVoice(id, false) + end end end - end - else - if unmutedPlayers[id] then - TogglePlayerVoice(id, false) + else + if unmutedPlayers[id] then + TogglePlayerVoice(id, false) + end end end end @@ -543,7 +549,9 @@ AddEventHandler("mumble:SetVoiceData", function(player, key, value) if voiceData[player][key] ~= nil then for id, _ in pairs(voiceData[player][key]) do if playerServerId == id then -- Check if the client has been removed from a nearby call - TogglePlayerVoice(player, false) -- Mute + if not vehiclePassengers[id] then -- Mute if player is not in client vehicle + TogglePlayerVoice(player, false) -- Mute + end end if playerServerId == player then -- Check if the client is a paricipant in the phone call whose voice is heard through the speaker @@ -571,7 +579,9 @@ AddEventHandler("mumble:SetVoiceData", function(player, key, value) for targetId, _ in pairs(voiceData[id].speakerTargets) do -- Loop through each call participants speaker targets if playerServerId == targetId then -- Check if the client was a target and mute the call - TogglePlayerVoice(id, false) -- Mute + if not vehiclePassengers[id] then -- Mute if player is not in client vehicle + TogglePlayerVoice(id, false) -- Mute + end end if playerServerId == id then -- Check if the client is a paricipant in the phone call whose voice is heard through the speaker From d71b6fba827fa9eda1c30ad1429384d3edd7e4d0 Mon Sep 17 00:00:00 2001 From: Fraser Watt <28698343+FrazzIe@users.noreply.github.com> Date: Thu, 3 Sep 2020 00:44:05 +0100 Subject: [PATCH 3/5] fix nil error --- client.lua | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/client.lua b/client.lua index ebfd9d8..9882679 100644 --- a/client.lua +++ b/client.lua @@ -712,11 +712,11 @@ Citizen.CreateThread(function() if mumbleConfig.radioEnabled then if not mumbleConfig.controls.radio.pressed then if IsControlJustPressed(0, mumbleConfig.controls.radio.key) then - if playerRadio > 0 then + if playerData.radio > 0 then SetVoiceData("radioActive", true) playerData.radioActive = true SetPlayerTargets(callTargets, speakerTargets, radioTargets) -- Send voice to everyone in the radio and call - PlayMicClick(playerRadio, true) + PlayMicClick(playerData.radio, true) mumbleConfig.controls.radio.pressed = true Citizen.CreateThread(function() @@ -726,7 +726,7 @@ Citizen.CreateThread(function() SetVoiceData("radioActive", false) SetPlayerTargets(callTargets, speakerTargets) -- Stop sending voice to everyone in the radio - PlayMicClick(playerRadio, false) + PlayMicClick(playerData.radio, false) playerData.radioActive = false mumbleConfig.controls.radio.pressed = false end) From 99f16339a13d23fdbc9baa0d972444341763a006 Mon Sep 17 00:00:00 2001 From: Fraser Watt <28698343+FrazzIe@users.noreply.github.com> Date: Thu, 3 Sep 2020 01:10:54 +0100 Subject: [PATCH 4/5] add vehiclePassengers to player targets, to ignore rapid zone changes --- client.lua | 83 ++++++++++++++++++++++++++++++++++-------------------- 1 file changed, 53 insertions(+), 30 deletions(-) diff --git a/client.lua b/client.lua index 9882679..ae221bc 100644 --- a/client.lua +++ b/client.lua @@ -9,7 +9,7 @@ local nearbySpeakerTargets = {} local resetTargets = false local playerChunk = nil local voiceTarget = 2 -local vehiclePassengers = {} +local vehicleTargets = {} local wasPlayerInVehicle = false -- Functions @@ -92,7 +92,7 @@ function SetGridTargets(pos, reset) -- Used to set the players voice targets dep DebugMsg("Current Chunk: " .. currentChunk .. ", Nearby Chunks: " .. nearbyChunksStr) if reset then - SetPlayerTargets(callTargets, speakerTargets, playerData.radioActive and radioTargets or nil) + SetPlayerTargets(callTargets, speakerTargets, vehicleTargets, playerData.radioActive and radioTargets or nil) resetTargets = false end @@ -235,8 +235,12 @@ function GetVehiclePassengers(vehicle) end function MuteVehiclePassengers(playerData) - for id, exists in pairs(vehiclePassengers) do + local changed = false + + for id, exists in pairs(vehicleTargets) do if exists then + changed = true + if playerData.radio > 0 or playerData.call > 0 then -- Only mute player if they are not in call or radio channel with client local remotePlayerData = voiceData[id] if remotePlayerData ~= nil then @@ -255,6 +259,8 @@ function MuteVehiclePassengers(playerData) end end end + + return changed end -- Events @@ -343,7 +349,7 @@ AddEventHandler("mumble:SetVoiceData", function(player, key, value) if CompareChannels(playerData, "radio", radioChannel) then if playerServerId ~= player then if unmutedPlayers[player] then - if not vehiclePassengers[player] then -- Mute if player is not in client vehicle + if not vehicleTargets[player] then -- Mute if player is not in client vehicle if playerData.call > 0 then -- Check if the client is in a call if not CompareChannels(voiceData[player], "call", playerData.call) then -- Check if the client is in a call with the unmuted player TogglePlayerVoice(player, false) @@ -361,7 +367,7 @@ AddEventHandler("mumble:SetVoiceData", function(player, key, value) for id, _ in pairs(radioData[radioChannel]) do -- Mute players that aren't supposed to be unmuted if id ~= playerServerId then if unmutedPlayers[id] then -- Check if a player isn't muted - if not vehiclePassengers[id] then -- Mute if player is not in client vehicle + if not vehicleTargets[id] then -- Mute if player is not in client vehicle if playerData.call > 0 then -- Check if the client is in a call if not CompareChannels(voiceData[id], "call", playerData.call) then -- Check if the client is in a call with the unmuted player TogglePlayerVoice(id, false) @@ -377,7 +383,7 @@ AddEventHandler("mumble:SetVoiceData", function(player, key, value) radioTargets = {} -- Remove all radio targets as client has left the radio channel if playerData.radioActive then - SetPlayerTargets(callTargets, speakerTargets) -- Reset active targets if for some reason if the client was talking on the radio when the client left + SetPlayerTargets(callTargets, speakerTargets, vehicleTargets) -- Reset active targets if for some reason if the client was talking on the radio when the client left end end end @@ -400,7 +406,7 @@ AddEventHandler("mumble:SetVoiceData", function(player, key, value) radioTargets[player] = true if playerData.radioActive then - SetPlayerTargets(callTargets, speakerTargets, radioTargets) + SetPlayerTargets(callTargets, speakerTargets, vehicleTargets, radioTargets) end end end @@ -426,7 +432,7 @@ AddEventHandler("mumble:SetVoiceData", function(player, key, value) if CompareChannels(playerData, "call", callChannel) then if playerServerId ~= player then if unmutedPlayers[player] then - if not vehiclePassengers[player] then -- Mute if player is not in client vehicle + if not vehicleTargets[player] then -- Mute if player is not in client vehicle if playerData.radio > 0 then -- Check if the client is in a call if not CompareChannels(voiceData[player], "radio", playerData.radio) then -- Check if the client is in a call with the unmuted player TogglePlayerVoice(player, false) @@ -439,13 +445,13 @@ AddEventHandler("mumble:SetVoiceData", function(player, key, value) if callTargets[player] then callTargets[player] = nil - SetPlayerTargets(callTargets, speakerTargets, playerData.radioActive and radioTargets or nil) + SetPlayerTargets(callTargets, speakerTargets, vehicleTargets, playerData.radioActive and radioTargets or nil) end elseif playerServerId == player then for id, _ in pairs(callData[callChannel]) do -- Mute players that aren't supposed to be unmuted if id ~= playerServerId then if unmutedPlayers[id] then -- Check if a player isn't muted - if not vehiclePassengers[id] then -- Mute if player is not in client vehicle + if not vehicleTargets[id] then -- Mute if player is not in client vehicle if playerData.radio > 0 then -- Check if the client is in a radio channel if not CompareChannels(voiceData[id], "radio", playerData.radio) then -- Check if the client isn't in the radio channel with the unmuted player TogglePlayerVoice(id, false) @@ -468,7 +474,7 @@ AddEventHandler("mumble:SetVoiceData", function(player, key, value) callTargets = {} -- Remove all call targets as client has left the call - SetPlayerTargets(callTargets, speakerTargets, playerData.radioActive and radioTargets or nil) -- Reset player targets + SetPlayerTargets(callTargets, speakerTargets, vehicleTargets, playerData.radioActive and radioTargets or nil) -- Reset player targets end end end @@ -490,7 +496,7 @@ AddEventHandler("mumble:SetVoiceData", function(player, key, value) if not callTargets[player] then callTargets[player] = true - SetPlayerTargets(callTargets, speakerTargets, playerData.radioActive and radioTargets or nil) + SetPlayerTargets(callTargets, speakerTargets, vehicleTargets, playerData.radioActive and radioTargets or nil) end end end @@ -504,7 +510,7 @@ AddEventHandler("mumble:SetVoiceData", function(player, key, value) if not callTargets[id] then callTargets[id] = true - SetPlayerTargets(callTargets, speakerTargets, playerData.radioActive and radioTargets or nil) + SetPlayerTargets(callTargets, speakerTargets, vehicleTargets, playerData.radioActive and radioTargets or nil) end end end @@ -549,7 +555,7 @@ AddEventHandler("mumble:SetVoiceData", function(player, key, value) if voiceData[player][key] ~= nil then for id, _ in pairs(voiceData[player][key]) do if playerServerId == id then -- Check if the client has been removed from a nearby call - if not vehiclePassengers[id] then -- Mute if player is not in client vehicle + if not vehicleTargets[id] then -- Mute if player is not in client vehicle TogglePlayerVoice(player, false) -- Mute end end @@ -565,7 +571,7 @@ AddEventHandler("mumble:SetVoiceData", function(player, key, value) end if speakerTargetsRemoved or #speakerTargetsAdded > 0 then - SetPlayerTargets(callTargets, speakerTargets, playerData.radioActive and radioTargets or nil) + SetPlayerTargets(callTargets, speakerTargets, vehicleTargets, playerData.radioActive and radioTargets or nil) end elseif key == "callSpeaker" and not value then if voiceData[player] ~= nil then @@ -579,7 +585,7 @@ AddEventHandler("mumble:SetVoiceData", function(player, key, value) for targetId, _ in pairs(voiceData[id].speakerTargets) do -- Loop through each call participants speaker targets if playerServerId == targetId then -- Check if the client was a target and mute the call - if not vehiclePassengers[id] then -- Mute if player is not in client vehicle + if not vehicleTargets[id] then -- Mute if player is not in client vehicle TogglePlayerVoice(id, false) -- Mute end end @@ -593,7 +599,7 @@ AddEventHandler("mumble:SetVoiceData", function(player, key, value) end if speakerTargetsRemoved then - SetPlayerTargets(callTargets, speakerTargets, playerData.radioActive and radioTargets or nil) + SetPlayerTargets(callTargets, speakerTargets, vehicleTargets, playerData.radioActive and radioTargets or nil) end end end @@ -658,7 +664,7 @@ AddEventHandler("mumble:RemoveVoiceData", function(player) callTargets[player] = nil speakerTargets[player] = nil - SetPlayerTargets(callTargets, speakerTargets, playerData.radioActive and radioTargets or nil) + SetPlayerTargets(callTargets, speakerTargets, vehicleTargets, playerData.radioActive and radioTargets or nil) end voiceData[player] = nil @@ -715,7 +721,7 @@ Citizen.CreateThread(function() if playerData.radio > 0 then SetVoiceData("radioActive", true) playerData.radioActive = true - SetPlayerTargets(callTargets, speakerTargets, radioTargets) -- Send voice to everyone in the radio and call + SetPlayerTargets(callTargets, speakerTargets, vehicleTargets, radioTargets) -- Send voice to everyone in the radio and call PlayMicClick(playerData.radio, true) mumbleConfig.controls.radio.pressed = true @@ -725,7 +731,7 @@ Citizen.CreateThread(function() end SetVoiceData("radioActive", false) - SetPlayerTargets(callTargets, speakerTargets) -- Stop sending voice to everyone in the radio + SetPlayerTargets(callTargets, speakerTargets, vehicleTargets) -- Stop sending voice to everyone in the radio PlayMicClick(playerData.radio, false) playerData.radioActive = false mumbleConfig.controls.radio.pressed = false @@ -930,6 +936,7 @@ Citizen.CreateThread(function() local playerId = PlayerId() local playerList = GetActivePlayers() local targets = {} + local targetList = "" local newPassengers = false for i = 1, #playerList do @@ -941,8 +948,14 @@ Citizen.CreateThread(function() targets[remotePlayerServerId] = true - if vehiclePassengers[remotePlayerServerId] then - vehiclePassengers[remotePlayerServerId] = nil + if targetList == "" then + targetList = remotePlayerServerId + else + targetList = targetList .. ", " .. remotePlayerServerId + end + + if vehicleTargets[remotePlayerServerId] then + vehicleTargets[remotePlayerServerId] = nil else newPassengers = true end @@ -950,30 +963,40 @@ Citizen.CreateThread(function() end end - MuteVehiclePassengers(playerData) + local removedPassengers = MuteVehiclePassengers(playerData) - if newPassengers then + vehicleTargets = targets + wasPlayerInVehicle = true + + if newPassengers or removedPassengers then for id, exists in pairs(targets) do - if exists then + if exists then TogglePlayerVoice(id, true) end end - end - vehiclePassengers = targets - wasPlayerInVehicle = true + if targetList ~= "" then + DebugMsg("Unmuted passengers: " .. targetList) + else + DebugMsg("Unmuting 0 passengers") + end + + SetPlayerTargets(callTargets, speakerTargets, vehicleTargets, playerData.radioActive and radioTargets or nil) + end else if wasPlayerInVehicle then MuteVehiclePassengers(playerData) - vehiclePassengers = {} + vehicleTargets = {} wasPlayerInVehicle = false + SetPlayerTargets(callTargets, speakerTargets, vehicleTargets, playerData.radioActive and radioTargets or nil) end end else if wasPlayerInVehicle then MuteVehiclePassengers(playerData) - vehiclePassengers = {} + vehicleTargets = {} wasPlayerInVehicle = false + SetPlayerTargets(callTargets, speakerTargets, vehicleTargets, playerData.radioActive and radioTargets or nil) end end end From 4c720faf80045690fa419c3c438d98b114698235 Mon Sep 17 00:00:00 2001 From: Fraser Watt <28698343+FrazzIe@users.noreply.github.com> Date: Thu, 3 Sep 2020 01:11:22 +0100 Subject: [PATCH 5/5] hopefully fix radios --- client.lua | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/client.lua b/client.lua index ae221bc..7829658 100644 --- a/client.lua +++ b/client.lua @@ -70,9 +70,8 @@ function SetGridTargets(pos, reset) -- Used to set the players voice targets dep end if reset then - MumbleClearVoiceTarget(voiceTarget) -- Reset voice target - MumbleSetVoiceTarget(voiceTarget) NetworkSetTalkerProximity(mumbleConfig.voiceModes[playerData.mode][1] + 0.0) -- Set voice proximity + MumbleClearVoiceTarget(voiceTarget) -- Reset voice target end if playerChunk ~= currentChunk or newGridTargets or reset then -- Only reset target channels if the current chunk or any nearby chunks have changed @@ -271,7 +270,7 @@ AddEventHandler("onClientResourceStart", function(resName) -- Initialises the sc DebugMsg("Initialising") - Citizen.Wait(2500) + Citizen.Wait(1000) if mumbleConfig.useExternalServer then MumbleSetServerAddress(mumbleConfig.externalAddress, mumbleConfig.externalPort) @@ -290,6 +289,13 @@ AddEventHandler("onClientResourceStart", function(resName) -- Initialises the sc SendNUIMessage({ warningId = "mumble_is_connected" }) end + Citizen.Wait(1000) + + MumbleClearVoiceTarget(voiceTarget) -- Reset voice target + MumbleSetVoiceTarget(voiceTarget) + + Citizen.Wait(1000) + voiceData[playerServerId] = { mode = 2, radio = 0,