refactor: require radar power to use state rather than toggle

This commit is contained in:
Dan
2021-03-12 20:12:03 +00:00
parent 2f9c483d6d
commit 8155fae94c
3 changed files with 24 additions and 26 deletions

View File

@@ -108,15 +108,8 @@ end
-- Event for receiving the radar powet state
RegisterNetEvent( "wk_wars2x_sync:receivePowerState" )
AddEventHandler( "wk_wars2x_sync:receivePowerState", function( state )
-- Get the current local radar power state
local power = RADAR:IsPowerOn()
-- If the local power state is not the same as the state sent, toggle the radar power
if ( power ~= state ) then
Citizen.SetTimeout( 100, function()
RADAR:TogglePower()
end )
end
-- Set the radar's power
RADAR:SetPowerState( state, false )
end )
-- Event for receiving a power state for the given antenna