Beep volume setting

This commit is contained in:
Dan
2019-12-01 20:04:58 +00:00
parent dafca61a63
commit b62de933ad
2 changed files with 13 additions and 9 deletions

View File

@@ -55,15 +55,18 @@ RADAR.vars =
["same"] = 4, ["same"] = 4,
["opp"] = 3, ["opp"] = 3,
["alert"] = true ["alert"] = true,
["beep"] = 1.0
}, },
menuActive = false, menuActive = false,
currentOptionIndex = 1, currentOptionIndex = 1,
menuOptions = { menuOptions = {
{ displayText = { "¦¦¦", "FAS" }, optionsText = { "On¦", "Off" }, options = { true, false }, optionIndex = 1, settingText = "fastDisplay" }, { displayText = { "¦¦¦", "FAS" }, optionsText = { "On¦", "Off" }, options = { true, false }, optionIndex = 1, settingText = "fastDisplay" },
{ displayText = { "¦SL", "SEn" }, optionsText = { "¦1¦", "¦2¦", "¦3¦", "¦4¦", "¦5¦" }, options = { 1, 2, 3, 4, 5 }, optionIndex = 4, settingText = "same" }, { displayText = { "¦SL", "SEn" }, optionsText = { "¦1¦", "¦2¦", "¦3¦", "¦4¦", "¦5¦" }, options = { 0.2, 0.4, 0.6, 0.8, 1.0 }, optionIndex = 4, settingText = "same" },
{ displayText = { "¦OP", "SEn" }, optionsText = { "¦1¦", "¦2¦", "¦3¦", "¦4¦", "¦5¦" }, options = { 1, 2, 3, 4, 5 }, optionIndex = 3, settingText = "opp" }, { displayText = { "¦OP", "SEn" }, optionsText = { "¦1¦", "¦2¦", "¦3¦", "¦4¦", "¦5¦" }, options = { 0.2, 0.4, 0.6, 0.8, 1.0 }, optionIndex = 3, settingText = "opp" },
{ displayText = { "¦¦b", "EEP" }, optionsText = { "¦1¦", "¦2¦", "¦3¦", "¦4¦", "¦5¦" }, options = { 0.2, 0.4, 0.6, 0.8, 1.0 }, optionIndex = 5, settingText = "beep" }
}, },
-- Player's vehicle speed, this is used to update the patrol vehicle speed on the radar -- Player's vehicle speed, this is used to update the patrol vehicle speed on the radar
@@ -479,7 +482,7 @@ end
function RADAR:UpdateRayEndCoords() function RADAR:UpdateRayEndCoords()
for k, v in pairs( self.rayTraces ) do for k, v in pairs( self.rayTraces ) do
local endY = ( self:GetSettingValue( v.rayType ) * 0.2 ) * v.endVec.baseY local endY = self:GetSettingValue( v.rayType ) * v.endVec.baseY
v.endVec.y = endY v.endVec.y = endY
end end
end end
@@ -821,7 +824,7 @@ RegisterNUICallback( "setAntennaMode", function( data )
end ) end )
end end
SendNUIMessage( { _type = "audio", name = "beep" } ) SendNUIMessage( { _type = "audio", name = "beep", vol = RADAR:GetSettingValue( "beep" ) } )
end ) end )
RegisterNUICallback( "toggleAntenna", function( data ) RegisterNUICallback( "toggleAntenna", function( data )
@@ -831,7 +834,7 @@ RegisterNUICallback( "toggleAntenna", function( data )
else else
RADAR:ToggleAntenna( data.value, function() RADAR:ToggleAntenna( data.value, function()
SendNUIMessage( { _type = "antennaXmit", ant = data.value, on = RADAR:IsAntennaTransmitting( data.value ) } ) SendNUIMessage( { _type = "antennaXmit", ant = data.value, on = RADAR:IsAntennaTransmitting( data.value ) } )
SendNUIMessage( { _type = "audio", name = RADAR:IsAntennaTransmitting( data.value ) and "xmit_on" or "xmit_off" } ) SendNUIMessage( { _type = "audio", name = RADAR:IsAntennaTransmitting( data.value ) and "xmit_on" or "xmit_off", vol = RADAR:GetSettingValue( "beep" ) } )
end ) end )
end end
end ) end )
@@ -845,7 +848,7 @@ RegisterNUICallback( "menu", function()
RADAR:SendMenuUpdate() RADAR:SendMenuUpdate()
end end
SendNUIMessage( { _type = "audio", name = "beep" } ) SendNUIMessage( { _type = "audio", name = "beep", vol = RADAR:GetSettingValue( "beep" ) } )
end ) end )

View File

@@ -306,9 +306,10 @@ function settingUpdate( ants, fast )
} }
} }
function playAudio( name ) function playAudio( name, vol )
{ {
let audio = new Audio( audioNames[name] ); let audio = new Audio( audioNames[name] );
audio.volume = vol;
audio.play(); audio.play();
} }
@@ -379,7 +380,7 @@ window.addEventListener( "message", function( event ) {
settingUpdate( item.antennaData, item.fast ); settingUpdate( item.antennaData, item.fast );
break; break;
case "audio": case "audio":
playAudio( item.name ); playAudio( item.name, item.vol );
break; break;
default: default:
break; break;