Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions client/init/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -32,19 +32,33 @@ AddEventHandler('onClientResourceStart', function(resource)
})

local radioChannel = LocalPlayer.state.radioChannel or 0
local secondaryRadioChannel = LocalPlayer.state.secondaryRadioChannel or 0
local callChannel = LocalPlayer.state.callChannel or 0

-- Reinitialize channels if they're set.
if radioChannel ~= 0 then
setRadioChannel(radioChannel)
end

if secondaryRadioChannel ~= 0 then
setSecondaryRadioChannel(secondaryRadioChannel)
end

if callChannel ~= 0 then
setCallChannel(callChannel)
end
if not LocalPlayer.state.disableRadio then
LocalPlayer.state:set("disableRadio", 0, true)
end

-- Fix initialization after resource restart
Citizen.CreateThread(function()
Citizen.Wait(5000)
-- Force initialization if mumble is connected but not initialized after restart
if MumbleIsConnected() and not isInitialized then
handleInitialState()
end
end)

print('Script initialization finished.')
end)
8 changes: 8 additions & 0 deletions client/init/main.lua
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ local volumes = {

radioEnabled, radioPressed, mode = true, false, GetConvarInt('voice_defaultVoiceMode', 2)
radioData = {}
secondaryRadioData = {}
callData = {}
submixIndicies = {}
--- function setVolume
Expand Down Expand Up @@ -180,6 +181,7 @@ function resyncVolume(volumeType, newVolume)
resyncVolume("call", newVolume)
elseif volumeType == "radio" then
updateVolumes(radioData, newVolume)
updateVolumes(secondaryRadioData, newVolume)
elseif volumeType == "call" then
updateVolumes(callData, newVolume)
end
Expand Down Expand Up @@ -315,6 +317,12 @@ function handleRadioAndCallInit()
toggleVoice(tgt, enabled, 'radio')
end
end

for tgt, enabled in pairs(secondaryRadioData) do
if tgt ~= playerServerId then
toggleVoice(tgt, enabled, 'radio')
end
end

for tgt, enabled in pairs(callData) do
if tgt ~= playerServerId then
Expand Down
1 change: 1 addition & 0 deletions client/init/proximity.lua
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ end)
local lastTalkingStatus = false
local lastRadioStatus = false
local voiceState = "proximity"

CreateThread(function()
TriggerEvent('chat:addSuggestion', '/muteply', 'Mutes the player with the specified id', {
{ name = "player id", help = "the player to toggle mute" },
Expand Down
4 changes: 2 additions & 2 deletions client/init/submix.lua
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ AddStateBagChangeHandler("submix", "", function(bagName, _, value)

-- we don't want to reset submix if the player is talking on the radio
if not value then
if not radioData[tgtId] and not callData[tgtId] then
if not radioData[tgtId] and not secondaryRadioData[tgtId] and not callData[tgtId] then
logger.info("Resetting submix for player %s", tgtId)
MumbleSetSubmixForServerId(tgtId, -1)
end
Expand All @@ -20,7 +20,7 @@ AddStateBagChangeHandler("submix", "", function(bagName, _, value)
end)

RegisterNetEvent("onPlayerDropped", function(tgtId)
if not radioData[tgtId] and not callData[tgtId] then
if not radioData[tgtId] and not secondaryRadioData[tgtId] and not callData[tgtId] then
logger.info("Resetting submix for player %s", tgtId)
MumbleSetSubmixForServerId(tgtId, -1)
end
Expand Down
7 changes: 4 additions & 3 deletions client/module/phone.lua
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,14 @@ RegisterNetEvent('pma-voice:removePlayerFromCall', function(plySource)
end
callData = {}
MumbleClearVoiceTargetPlayers(voiceTarget)
addVoiceTargets((radioPressed and isRadioEnabled()) and radioData or {}, callData)
addVoiceTargets((radioPressed and isRadioEnabled()) and getCombinedRadioData() or {}, callData)
else
callData[plySource] = nil
toggleVoice(plySource, radioData[plySource], 'call')
local isOnRadio = radioData[plySource] or secondaryRadioData[plySource]
toggleVoice(plySource, isOnRadio, 'call')
if MumbleIsPlayerTalking(PlayerId()) then
MumbleClearVoiceTargetPlayers(voiceTarget)
addVoiceTargets((radioPressed and isRadioEnabled()) and radioData or {}, callData)
addVoiceTargets((radioPressed and isRadioEnabled()) and getCombinedRadioData() or {}, callData)
end
end
end)
Expand Down
Loading