Drawing a temporary fading red rectangle

I want to draw a red rectangle on the player’s screen that slowly fades away completely after 2 seconds, I’m not sure how to do the fading away stuff, with CurTime()? Timers? plz help =S

I suppose you could do something like this (untested)

local time
local alpha

function DoRectangle()

//set time     
time = (CurTime() + 2)     
alpha = 255  


function RectanglePaint()

if (alpha == 0) then return end     
if (CurTime() > time) then          
    //reduce alpha         
    alpha = (alpha - 1)     

//draw rect     
surface.SetDrawColor(255, 0, 0, alpha)     
surface.DrawRect(0, 0, ScrW(), ScrH())      


hook.Add(“HUDPaint”, “DoRedRectangle”, RectanglePaint)

google is your friend

I googled already…