mirror of
https://github.com/Michatec/wk_wars2x.git
synced 2026-04-01 08:26:27 +02:00
fix: power button spam breaking display
This commit is contained in:
45
cl_radar.lua
45
cl_radar.lua
@@ -379,32 +379,35 @@ end
|
|||||||
|
|
||||||
-- Toggles the radar power
|
-- Toggles the radar power
|
||||||
function RADAR:TogglePower()
|
function RADAR:TogglePower()
|
||||||
-- Toggle the power variable
|
-- Only power up if the system is not already powering up
|
||||||
self.vars.power = not self.vars.power
|
if ( not self:IsPoweringUp() ) then
|
||||||
|
-- Toggle the power variable
|
||||||
|
self.vars.power = not self.vars.power
|
||||||
|
|
||||||
-- Send the NUI message to toggle the power
|
-- Send the NUI message to toggle the power
|
||||||
SendNUIMessage( { _type = "radarPower", state = self:IsPowerOn() } )
|
SendNUIMessage( { _type = "radarPower", state = self:IsPowerOn() } )
|
||||||
|
|
||||||
-- Power is now turned on
|
-- Power is now turned on
|
||||||
if ( self:IsPowerOn() ) then
|
if ( self:IsPowerOn() ) then
|
||||||
-- Also make sure the operator menu is inactive
|
-- Also make sure the operator menu is inactive
|
||||||
self:SetMenuState( false )
|
self:SetMenuState( false )
|
||||||
|
|
||||||
-- Tell the system the radar is 'powering up'
|
-- Tell the system the radar is 'powering up'
|
||||||
self:SetPoweringUpState( true )
|
self:SetPoweringUpState( true )
|
||||||
|
|
||||||
-- Set a 2 second countdown
|
-- Set a 2 second countdown
|
||||||
Citizen.SetTimeout( 2000, function()
|
Citizen.SetTimeout( 2000, function()
|
||||||
-- Tell the system the radar has 'powered up'
|
-- Tell the system the radar has 'powered up'
|
||||||
self:SetPoweringUpState( false )
|
self:SetPoweringUpState( false )
|
||||||
|
|
||||||
-- Let the UI side know the system has loaded
|
-- Let the UI side know the system has loaded
|
||||||
SendNUIMessage( { _type = "poweredUp" } )
|
SendNUIMessage( { _type = "poweredUp" } )
|
||||||
end )
|
end )
|
||||||
else
|
else
|
||||||
-- If the system is being turned off, then we reset the antennas
|
-- If the system is being turned off, then we reset the antennas
|
||||||
self:ResetAntenna( "front" )
|
self:ResetAntenna( "front" )
|
||||||
self:ResetAntenna( "rear" )
|
self:ResetAntenna( "rear" )
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user