mirror of
https://github.com/Michatec/wk_wars2x.git
synced 2026-04-01 08:26:27 +02:00
refactor: remove callback from RADAR:SetAntennaMode()
This commit is contained in:
17
cl_radar.lua
17
cl_radar.lua
@@ -1007,7 +1007,7 @@ end
|
|||||||
|
|
||||||
-- Sets the mode of the given antenna if the mode is valid and the power is on. Also runs a callback function
|
-- Sets the mode of the given antenna if the mode is valid and the power is on. Also runs a callback function
|
||||||
-- when present.
|
-- when present.
|
||||||
function RADAR:SetAntennaMode( ant, mode, cb )
|
function RADAR:SetAntennaMode( ant, mode )
|
||||||
-- Check the mode is actually a number, this is needed as the radar system relies on the mode to be
|
-- Check the mode is actually a number, this is needed as the radar system relies on the mode to be
|
||||||
-- a number to work
|
-- a number to work
|
||||||
if ( type( mode ) == "number" ) then
|
if ( type( mode ) == "number" ) then
|
||||||
@@ -1016,8 +1016,11 @@ function RADAR:SetAntennaMode( ant, mode, cb )
|
|||||||
-- Update the mode for the antenna
|
-- Update the mode for the antenna
|
||||||
self.vars.antennas[ant].mode = mode
|
self.vars.antennas[ant].mode = mode
|
||||||
|
|
||||||
-- Run the callback function if there is one
|
-- Update the interface with the new mode
|
||||||
if ( cb ) then cb() end
|
SendNUIMessage( { _type = "antennaMode", ant = ant, mode = mode } )
|
||||||
|
|
||||||
|
-- Play a beep
|
||||||
|
SendNUIMessage( { _type = "audio", name = "beep", vol = self:GetSettingValue( "beep" ) } )
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -1529,16 +1532,10 @@ RegisterNUICallback( "setAntennaMode", function( data, cb )
|
|||||||
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 ) )
|
||||||
-- Update the interface with the new mode
|
|
||||||
SendNUIMessage( { _type = "antennaMode", ant = data.value, mode = tonumber( data.mode ) } )
|
|
||||||
|
|
||||||
-- Play a beep
|
|
||||||
SendNUIMessage( { _type = "audio", name = "beep", vol = RADAR:GetSettingValue( "beep" ) } )
|
|
||||||
|
|
||||||
-- Sync
|
-- Sync
|
||||||
SYNC:SendAntennaMode( data.value, tonumber( data.mode ) )
|
SYNC:SendAntennaMode( data.value, tonumber( data.mode ) )
|
||||||
end )
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -90,11 +90,5 @@ end )
|
|||||||
|
|
||||||
RegisterNetEvent( "wk_wars2x_sync:receiveAntennaMode" )
|
RegisterNetEvent( "wk_wars2x_sync:receiveAntennaMode" )
|
||||||
AddEventHandler( "wk_wars2x_sync:receiveAntennaMode", function( antenna, mode )
|
AddEventHandler( "wk_wars2x_sync:receiveAntennaMode", function( antenna, mode )
|
||||||
RADAR:SetAntennaMode( antenna, mode, function()
|
RADAR:SetAntennaMode( antenna, mode )
|
||||||
-- Update the interface with the new mode
|
|
||||||
SendNUIMessage( { _type = "antennaMode", ant = antenna, mode = mode } )
|
|
||||||
|
|
||||||
-- Play a beep
|
|
||||||
SendNUIMessage( { _type = "audio", name = "beep", vol = RADAR:GetSettingValue( "beep" ) } )
|
|
||||||
end )
|
|
||||||
end )
|
end )
|
||||||
Reference in New Issue
Block a user