How do I add an "Icon" on the screen?

I want to add something like this:

(Paint level 9000)

How do I do that? I mean, I have the “triggers” but how do I make it so an transparent image appears in the middle-bottom part of the screen saying “Press Alt to do something” or how do I put some text saying that?

Thanks!

If you want to add text on the screen, try looking into the surface library.



function PaintCustomHUD()
	draw.DrawText("Press ALT to do something", "Default", 40,40,Color(255,255,255,255),0)	
end
hook.Add("HUDPaint", "Whatever", PaintCustomHUD)


Put that in a lua file and send it to the client.

Yeah, the thing is that I want to do that when a trace hits something, how do I do that?



		function Thing()
		for id,ply in pairs ( player.GetAll( ) ) do
			tracedata={}
				tracedata.start = ply:EyePos()
				tracedata.endpos = ply:EyePos()+(ply:GetAimVector()*64)
				tracedata.filter = ply
				local trace = util.TraceLine(tracedata)
				if trace.Hit then
---here should be the press alt to do something thing--


You’d have to hook the entire function into a HUDPaint hook like so:
[lua]
ply = LocalPlayer()
hook.Add( “HUDPaint”, “DrawMessage”, function()

tracedata={}
tracedata.start = ply:EyePos()
tracedata.endpos = ply:EyePos()+(ply:GetAimVector()*64)
tracedata.filter = ply
local trace = util.TraceLine(tracedata)
if trace.Hit then
	draw.DrawText( "Press ALT to peek", "Default", 40, 40, Color( 255, 255, 255 ) )
end

end )
[/lua]
This would only be needed clientside, since the surface library and the HUDPaint hook only work clientside.

To draw an icon use this:

Where _mat is a Material( ) defined outside of the HUDPaint, and _x, _y are the location, and _w, _h are the width and height of the material.
[lua]surface.SetMaterial( _mat );
surface.SetDrawColor( Color( 255, 255, 255, 255 ) );
surface.DrawTexturedRect( _x, _y, _w, _h );[/lua]

Thank you!

Is there any way to change the size?

You’d have to make your own font using surface.CreateFont

Thank you!