Mouse lagging bug

Well, since I used this for my hud…
DImage…


   local coinimage
   if !IsValid(coinimage) then
		coinimage = vgui.Create("DImage")
		coinimage:SetSize(25, 25)
		coinimage:SetPos(120, ScrH() - 83)
		coinimage:SetImage("coin.png", "vgui/avatar_default")
   end

Inside of Hud Paint, when someone goes to something like the TAB there mouse just SPAZZES OUT like you can’t click on anything, and you can’t click on anything in the Q menu either! And when I use DAvatar its exactly the same, these images are just put on the screen… but lag the mouse like no tommorrow

[editline]7th August 2016[/editline]

:zoid: Please Help… :~

[editline]7th August 2016[/editline]

Please?

Instead of a DImage, try using

surface.DrawTexturedRect, e.g.



local mat = Material( 'coin.png', 'noclamp smooth' ) -- the 'smooth' thing makes it look nicer usually

hook.Add( 'HUDPaint', 'test', function()
    surface.SetDrawColor( 255, 255, 255 )
    surface.SetMaterial( mat )
    surface.DrawTexturedRect( 120, ScrH() - 83, 25, 25 )
end )


[editline]7th August 2016[/editline]

Also, if that’s in a HUDPaint hook, the



local coinimage


Should be OUTSIDE the hook, e.g.



local coinimage

hook.Add( 'HUDPaint', 'blah', function()
   if !IsValid(coinimage) then
		coinimage = vgui.Create("DImage")
		coinimage:SetSize(25, 25)
		coinimage:SetPos(120, ScrH() - 83)
		coinimage:SetImage("coin.png", "vgui/avatar_default")
   end
end )