Passenger control for setting antenna mode

This commit is contained in:
Dan
2020-11-29 15:21:29 +00:00
parent fb13e79e3b
commit 3d9658d2d5

View File

@@ -1544,31 +1544,33 @@ end )
-- Runs when the user presses any of the antenna mode buttons on the remote -- Runs when the user presses any of the antenna mode buttons on the remote
RegisterNUICallback( "setAntennaMode", function( data, cb ) RegisterNUICallback( "setAntennaMode", function( data, cb )
-- Only run the codw if the radar has power and is not powering up if ( PLY:CanControlRadar() ) then
if ( RADAR:IsPowerOn() and not RADAR:IsPoweringUp() ) then -- Only run the codw if the radar has power and is not powering up
-- As the mode buttons are used to exit the menu, we check for that if ( RADAR:IsPowerOn() and not RADAR:IsPoweringUp() ) then
if ( RADAR:IsMenuOpen() ) then -- As the mode buttons are used to exit the menu, we check for that
-- Set the internal menu state to be closed (false) if ( RADAR:IsMenuOpen() ) then
RADAR:SetMenuState( false ) -- Set the internal menu state to be closed (false)
RADAR:SetMenuState( false )
-- Send a setting update to the NUI side -- Send a setting update to the NUI side
RADAR:SendSettingUpdate() RADAR:SendSettingUpdate()
-- Play a menu done beep -- Play a menu done beep
SendNUIMessage( { _type = "audio", name = "done", vol = RADAR:GetSettingValue( "beep" ) } ) SendNUIMessage( { _type = "audio", name = "done", vol = RADAR:GetSettingValue( "beep" ) } )
-- Save the operator menu values -- Save the operator menu values
local omData = json.encode( RADAR.vars.settings ) local omData = json.encode( RADAR.vars.settings )
SetResourceKvp( "wk_wars2x_om_data", omData ) SetResourceKvp( "wk_wars2x_om_data", omData )
else else
-- Change the mode for the designated antenna, pass along a callback which contains data from this NUI callback -- Change the mode for the designated antenna, pass along a callback which contains data from this NUI callback
RADAR:SetAntennaMode( data.value, tonumber( data.mode ), function() RADAR:SetAntennaMode( data.value, tonumber( data.mode ), function()
-- Update the interface with the new mode -- Update the interface with the new mode
SendNUIMessage( { _type = "antennaMode", ant = data.value, mode = tonumber( data.mode ) } ) SendNUIMessage( { _type = "antennaMode", ant = data.value, mode = tonumber( data.mode ) } )
-- Play a beep -- Play a beep
SendNUIMessage( { _type = "audio", name = "beep", vol = RADAR:GetSettingValue( "beep" ) } ) SendNUIMessage( { _type = "audio", name = "beep", vol = RADAR:GetSettingValue( "beep" ) } )
end ) end )
end
end end
end end