Hello BogdanRTB,
I think that @IIYAMA has made a wonderful solution if you want the UI to blend in and out using alpha. If you want to simulate a beep-like appearing and disappearing then I think that you might be interested in instant animation instead. This can be solved by the use of a simple timer in connection with the "beep"-duration.
-- The beep duration basically how long a visibility or non-visibility phase
-- is supposed to last.
local beepDuration = 1000;
-- This is the variable that you should use in your DX UI to determine whether
-- to draw it or not. You should reset it to true when you "call" your DX UI.
local is_dx_ui_beep_visible = true;
-- This variable should store the timer. It should be reset if the DX UI is "called".
local uiBeepTimer = false;
-- Call this function whenever you "call" or show your DX GUI.
local call_dx_gui()
is_dx_ui_beep_visible = true;
uiBeepTimer = setTimer(
function()
is_dx_ui_beep_visible = not is_dx_ui_beep_visible;
end, beepDuration, 0
);
end
-- Call this function whenever you hide your DX GUI.
local hide_dx_gui()
is_dx_ui_beep_visible = false;
killTimer(uiBeepTimer);
end
-- Example drawing code.
local show_dx_gui = true;
call_dx_gui();
addEventHandler("onClientRender", root,
function()
if (show_dx_gui) and (is_dx_ui_beep_visible) then
dxDrawRectangle(100, 100, 400, 400, tocolor(255, 0, 0, 255));
end
end
);