Skip to content

Commit

Permalink
tweak(radio): make syncing players name optional
Browse files Browse the repository at this point in the history
  • Loading branch information
AvarianKnight committed Jan 1, 2022
1 parent a8353ec commit b6f0ae4
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
12 changes: 9 additions & 3 deletions client/module/radio.lua
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@ function syncRadioData(radioTable, localPlyRadioName)
toggleVoice(tgt, enabled, 'radio')
end
end
radioNames[playerServerId] = localPlyRadioName
if GetConvarInt("voice_syncPlayerNames", 0) == 1 then
radioNames[playerServerId] = localPlyRadioName
end
end
RegisterNetEvent('pma-voice:syncRadioData', syncRadioData)

Expand All @@ -38,7 +40,9 @@ RegisterNetEvent('pma-voice:setTalkingOnRadio', setTalkingOnRadio)
---@param plySource number the players server id to add to the radio.
function addPlayerToRadio(plySource, plyRadioName)
radioData[plySource] = false
radioNames[plySource] = plyRadioName
if GetConvarInt("voice_syncPlayerNames", 0) == 1 then
radioNames[plySource] = plyRadioName
end
if radioPressed then
logger.info('[radio] %s joined radio %s while we were talking, adding them to targets', plySource, radioChannel)
playerTargets(radioData, MumbleIsPlayerTalking(PlayerId()) and callData or {})
Expand Down Expand Up @@ -71,7 +75,9 @@ function removePlayerFromRadio(plySource)
logger.info('[radio] %s has left radio %s', plySource, radioChannel)
end
radioData[plySource] = nil
radioNames[plySource] = nil
if GetConvarInt("voice_syncPlayerNames", 0) == 1 then
radioNames[plySource] = nil
end
end
end
RegisterNetEvent('pma-voice:removePlayerFromRadio', removePlayerFromRadio)
Expand Down
3 changes: 1 addition & 2 deletions server/module/radio.lua
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,9 @@ function addPlayerToRadio(source, radioChannel)
TriggerClientEvent('pma-voice:addPlayerToRadio', player, source, plyName)
end
voiceData[source] = voiceData[source] or defaultTable(source)

voiceData[source].radio = radioChannel
radioData[radioChannel][source] = false
TriggerClientEvent('pma-voice:syncRadioData', source, radioData[radioChannel], plyName)
TriggerClientEvent('pma-voice:syncRadioData', source, radioData[radioChannel], GetConvarInt("voice_syncPlayerNames", 0) == 1 and plyName)
end

--- removes a player from the specified channel
Expand Down

0 comments on commit b6f0ae4

Please sign in to comment.