UserMessage Hud Paint

I am trying to make this hud part draw when the usermessage arrives but it seems to do nothing, the message is coming through fine and works with print but it won’t seem to paint this. I have tried adding a paint hook inside the function but it deems um as a nil value, and same thing happens when I hook it into my main paint function? Any ideas?

[lua]
function Alerts( um )
local Exclamation = surface.GetTextureID( “shane/hud/exclamation” )
local AlertUM = um:ReadString()
local Size = surface.GetTextSize( AlertUM )
//Image Box
draw.RoundedBox( 0, 4, ( ScrH() / 180 - 2 ), 24, 20, Color( 0, 0, 0, 200 ) )
//TextBox
draw.RoundedBox( 0, 30, ( ScrH() / 180 - 2 ), Size + 7, 20, Color( 0, 0, 0, 200 ) )
//Alert Texture
surface.SetTexture( Exclamation )
surface.SetDrawColor( 255, 255, 255, 255 )
surface.DrawTexturedRect( 8, ScrH() / 180, 16, 16 )
//Alert Text
draw.SimpleText( AlertUM, “ScoreboardText”, 34, ScrH() / 180, Color( 255, 255, 255, 255 ), TEXT_ALIGN_LEFT, TEXT_ALIGN_LEFT )

end
usermessage.Hook( “Alert”, Alerts )
[/lua]

For a HUD to appear, you need to draw it every frame, so it isn’t going to work the way you are doing it now. You need to add the exclamations to a queue and draw them using HUDPaint.

Seems where ever I call the function in a paint hook it sees um as a nil value, but works fine outside of a paint function.

You need to Add the alerts to a table, like Overv said, in the usermessage hook and draw the text from the table in a HUDPaint hook.