Removing vgui avatar picture

In a custom hud im making i use the the players avatar but its causing lag issues that cause gmod to crash, Ive been trying to figure out how to remove the old vgui avatar after a new one has been drawn.

the code :http://pastebin.com/m0j0TiV8

any help would be great

You’re creating an avatar every frame, just create one and then check if avatar is valid, if it’s not valid, then create a new one

If you need help with that



local Avatar -- don't set this as anything yet

local function Base()

    -- insert all the other stuff before the avatar part here

    if !IsValid( Avatar ) then
        Avatar = vgui.Create( "AvatarImage" )
        Avatar:SetSize( 64, 64 )
        Avatar:SetPos( width1 - 1555, height1 - 185 )
        Avatar:SetPlayer( LocalPlayer(), 64 )
    end

end


whats the best way to alter that code so it hides the avatar while the player is typing in chat?

thanks for your help

Just use

GM:StartChat and

GM:FinishChat and change the avatar’s visibility

[editline]21st August 2016[/editline]



hook.Add( 'StartChat', 'blah', function()
	Avatar:SetVisible( false )
end )
hook.Add( 'FinishChat', 'blah', function()
	Avatar:SetVisible( true )
end )