Skip to content

Commit

Permalink
chore(deps-dev): bump elliptic from 6.5.4 to 6.5.7 in /voice-ui
Browse files Browse the repository at this point in the history
  • Loading branch information
bitpredator committed Aug 18, 2024
1 parent 30de5cd commit 5cbb938
Show file tree
Hide file tree
Showing 8 changed files with 4,913 additions and 3,968 deletions.
10 changes: 10 additions & 0 deletions server-data/resources/[phone]/pma-voice/TODO.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
## TODO
- [ ] Ability to display radio members on the client.
- [ ] Use commands to define voiceModes in shared.lua and only leave debug logs in shared.lua.
- [ ] Convert the UI to React.
- [ ] Multiple radio channels.

## DONE
- [ x ] Implement a easy way to get the players current radio channel on the server.
- [ x ] Add the ability to override proximity with exports.
- [ x ] Rename everything that uses 'phone' to 'call' for consistency.
122 changes: 59 additions & 63 deletions server-data/resources/[phone]/pma-voice/client/commands.lua
Original file line number Diff line number Diff line change
@@ -1,87 +1,83 @@
local wasProximityDisabledFromOverride = false
disableProximityCycle = false
RegisterCommand("setvoiceintent", function(source, args)
if GetConvarInt("voice_allowSetIntent", 1) == 1 then
local intent = args[1]
if intent == "speech" then
MumbleSetAudioInputIntent(`speech`)
elseif intent == "music" then
MumbleSetAudioInputIntent(`music`)
end
LocalPlayer.state:set("voiceIntent", intent, true)
end
RegisterCommand('setvoiceintent', function(source, args)
if GetConvarInt('voice_allowSetIntent', 1) == 1 then
local intent = args[1]
if intent == 'speech' then
MumbleSetAudioInputIntent(`speech`)
elseif intent == 'music' then
MumbleSetAudioInputIntent(`music`)
end
LocalPlayer.state:set('voiceIntent', intent, true)
end
end)
TriggerEvent("chat:addSuggestion", "/setvoiceintent", "Sets the players voice intent", {
{
name = "intent",
help = "speech is default and enables noise suppression & high pass filter, music disables both of these.",
},
TriggerEvent('chat:addSuggestion', '/setvoiceintent', 'Sets the players voice intent', {
{
name = "intent",
help = "speech is default and enables noise suppression & high pass filter, music disables both of these."
},
})

-- TODO: Better implementation of this?
RegisterCommand("vol", function(_, args)
if not args[1] then
return
end
setVolume(tonumber(args[1]))
RegisterCommand('vol', function(_, args)
if not args[1] then return end
setVolume(tonumber(args[1]))
end)
TriggerEvent("chat:addSuggestion", "/vol", "Sets the radio/phone volume", {
{ name = "volume", help = "A range between 1-100 on how loud you want them to be" },
TriggerEvent('chat:addSuggestion', '/vol', 'Sets the radio/phone volume', {
{ name = "volume", help = "A range between 1-100 on how loud you want them to be" },
})

exports("setAllowProximityCycleState", function(state)
type_check({ state, "boolean" })
disableProximityCycle = state
exports('setAllowProximityCycleState', function(state)
type_check({ state, "boolean" })
disableProximityCycle = state
end)

function setProximityState(proximityRange, isCustom)
local voiceModeData = Cfg.voiceModes[mode]
MumbleSetTalkerProximity(proximityRange + 0.0)
LocalPlayer.state:set("proximity", {
index = mode,
distance = proximityRange,
mode = isCustom and "Custom" or voiceModeData[2],
}, true)
sendUIMessage({
-- JS expects this value to be - 1, "custom" voice is on the last index
voiceMode = isCustom and #Cfg.voiceModes or mode - 1,
})
local voiceModeData = Cfg.voiceModes[mode]
MumbleSetTalkerProximity(proximityRange + 0.0)
LocalPlayer.state:set('proximity', {
index = mode,
distance = proximityRange,
mode = isCustom and "Custom" or voiceModeData[2],
}, true)
sendUIMessage({
-- JS expects this value to be - 1, "custom" voice is on the last index
voiceMode = isCustom and #Cfg.voiceModes or mode - 1
})
end

exports("overrideProximityRange", function(range, disableCycle)
type_check({ range, "number" })
setProximityState(range, true)
if disableCycle then
disableProximityCycle = true
wasProximityDisabledFromOverride = true
end
type_check({ range, "number" })
setProximityState(range, true)
if disableCycle then
disableProximityCycle = true
wasProximityDisabledFromOverride = true
end
end)

exports("clearProximityOverride", function()
local voiceModeData = Cfg.voiceModes[mode]
setProximityState(voiceModeData[1], false)
if wasProximityDisabledFromOverride then
disableProximityCycle = false
end
local voiceModeData = Cfg.voiceModes[mode]
setProximityState(voiceModeData[1], false)
if wasProximityDisabledFromOverride then
disableProximityCycle = false
end
end)

RegisterCommand("cycleproximity", function()
-- Proximity is either disabled, or manually overwritten.
if GetConvarInt("voice_enableProximityCycle", 1) ~= 1 or disableProximityCycle then
return
end
local newMode = mode + 1
RegisterCommand('cycleproximity', function()
-- Proximity is either disabled, or manually overwritten.
if GetConvarInt('voice_enableProximityCycle', 1) ~= 1 or disableProximityCycle then return end
local newMode = mode + 1

-- If we're within the range of our voice modes, allow the increase, otherwise reset to the first state
if newMode <= #Cfg.voiceModes then
mode = newMode
else
mode = 1
end
-- If we're within the range of our voice modes, allow the increase, otherwise reset to the first state
if newMode <= #Cfg.voiceModes then
mode = newMode
else
mode = 1
end

setProximityState(Cfg.voiceModes[mode][1], false)
TriggerEvent("pma-voice:setTalkingMode", mode)
setProximityState(Cfg.voiceModes[mode][1], false)
TriggerEvent('pma-voice:setTalkingMode', mode)
end, false)
if gameVersion == "fivem" then
RegisterKeyMapping("cycleproximity", "Cycle Proximity", "keyboard", GetConvar("voice_defaultCycle", "F11"))
if gameVersion == 'fivem' then
RegisterKeyMapping('cycleproximity', 'Cycle Proximity', 'keyboard', GetConvar('voice_defaultCycle', 'F11'))
end
22 changes: 12 additions & 10 deletions server-data/resources/[phone]/pma-voice/server/main.lua
Original file line number Diff line number Diff line change
Expand Up @@ -56,27 +56,29 @@ CreateThread(function()

Wait(5000)

local nativeAudio = GetConvar('voice_useNativeAudio', 'false')
local _3dAudio = GetConvar('voice_use3dAudio', 'false')
local _2dAudio = GetConvar('voice_use2dAudio', 'false')
local sendingRangeOnly = GetConvar('voice_useSendingRangeOnly', 'false')
local nativeAudio = GetConvar('voice_useNativeAudio', 'not-set')
local _3dAudio = GetConvar('voice_use3dAudio', 'not-set')
local _2dAudio = GetConvar('voice_use2dAudio', 'not-set')
local sendingRangeOnly = GetConvar('voice_useSendingRangeOnly', 'not-set')
local gameVersion = GetConvar('gamename', 'fivem')

-- handle no convars being set (default drag n' drop)
if
nativeAudio == 'false'
and _3dAudio == 'false'
and _2dAudio == 'false'
nativeAudio == 'not-set'
and _3dAudio == 'not-set'
and _2dAudio == 'not-set'
then
SetConvarReplicated('voice_useNativeAudio', 'true')
if sendingRangeOnly == 'false' then
if sendingRangeOnly == 'not-set' then
SetConvarReplicated('voice_useSendingRangeOnly', 'true')
logger.info(
'No convars detected for voice mode, defaulting to \'setr voice_useNativeAudio true\' and \'setr voice_useSendingRangeOnly true\'')
else
logger.info('No voice mod detected, defaulting to \'setr voice_useNativeAudio true\'')
end
elseif sendingRangeOnly == 'false' then
elseif sendingRangeOnly == 'not-set' then
logger.warn(
"It's recommended to have 'voice_useSendingRangeOnly' set to true you can do that with 'setr voice_useSendingRangeOnly true', this prevents players who directly join the mumble server from broadcasting to players.")
"It's recommended to have 'voice_useSendingRangeOnly' set to true, you can do that with 'setr voice_useSendingRangeOnly true', this prevents players who directly join the mumble server from broadcasting to players.")
end

local radioVolume = GetConvarInt("voice_defaultRadioVolume", 30)
Expand Down
15 changes: 7 additions & 8 deletions server-data/resources/[phone]/pma-voice/server/mute.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
const mutedPlayers = {};
let mutedPlayers = {}
// this is implemented in JS due to Lua's lack of a ClearTimeout
// muteply instead of mute because mute conflicts with rp-radio
RegisterCommand('muteply', (source, args) => {
const mutePly = parseInt(args[0]);
// eslint-disable-next-line semi
const mutePly = parseInt(args[0])
const duration = parseInt(args[1]) || 900
if (mutePly && exports[GetCurrentResourceName()].isValidPlayer(mutePly)) {
const isMuted = !MumbleIsPlayerMuted(mutePly);
Expand All @@ -14,14 +13,14 @@ RegisterCommand('muteply', (source, args) => {
// that they're currently muted, so we'll clear the timeout and unmute
if (mutedPlayers[mutePly]) {
clearTimeout(mutedPlayers[mutePly]);
MumbleSetPlayerMuted(mutePly, isMuted);
MumbleSetPlayerMuted(mutePly, isMuted)
Player(mutePly).state.muted = isMuted;
return;
}
mutedPlayers[mutePly] = setTimeout(() => {
MumbleSetPlayerMuted(mutePly, !isMuted);
MumbleSetPlayerMuted(mutePly, !isMuted)
Player(mutePly).state.muted = !isMuted;
delete mutedPlayers[mutePly];
}, duration * 1000);
delete mutedPlayers[mutePly]
}, duration * 1000)
}
}, true);
}, true)
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module.exports = {
presets: [
'@vue/cli-plugin-babel/preset',
],
};
presets: [
'@vue/cli-plugin-babel/preset'
]
}
Loading

0 comments on commit 5cbb938

Please sign in to comment.