Best hook for drawing avatars once on the HUD? (InitPostEntity doesnt seem to be working)
6 replies, posted
For some reason (although this could be due to me running in single player and not on a server) the InitPostEntity hook isnt calling at all.. I cant draw my avatar on a HUD im working on as a result. Are there any other hooks I can use?
This is how im using my InitPostEntity hook:
[lua]
hook.Add("InitPostEntity","DrawAvatarRightFuckingNow", function()
DrawAvatar()
print("hi")
end)
[/lua]
That hi message isnt appearing anywhere, I have tried making it longer incase I missed it but nope.
You don't really need a hook for it. Just putting it inside the file without a hook seems to work fine for me:
[lua]if not HUD.Avatar then
HUD.Avatar = vgui.Create( "AvatarImage" )
HUD.Avatar:SetSize( 32, 32 )
HUD.Avatar:SetPos( 2.5, 2.5 )
HUD.Avatar:SetVisible( false )
HUD.Avatar:SetDrawOnTop( true )
HUD.Avatar.Think = function()
if gui.IsGameUIVisible() or gui.IsConsoleVisible() then
HUD.Avatar:SetVisible( false )
end
end
end[/lua]
Pretty sure with an AvatarImage you have to set the player or you'll just get a question mark image.
[code]
if not HUD.Avatar then
HUD.Avatar = vgui.Create( "AvatarImage" )
HUD.Avatar:SetSize( 32, 32 )
HUD.Avatar:SetPos( 2.5, 2.5 )
HUD.Avatar:SetVisible( false )
HUD.Avatar:SetDrawOnTop( true )
HUD.Avatar:SetPlayer( LocalPlayer(), 64 )
HUD.Avatar.Think = function()
if gui.IsGameUIVisible() or gui.IsConsoleVisible() then
HUD.Avatar:SetVisible( false )
end
end
end
[/code]
Yes, but it appears, and that's what his question was asking about. I just posted this here because it's what I have (just as an example). I automatically hide it once it's created, though.
I thought gui.IsGameUIVisible() hides it if the main menu's open and gui.IsConsoleVisible() hides it when the console's open.
I see a ton of servers that have the problem where their HUD AvatarImage is overlapping the main menu which gets quite annoying.
Oh, it does, the hiding is also done in a HUDPaint hook for no reason at all, that handles it for me.
I agree, the instant I noticed how the avatar image was visible in the menu I added the Think to ensure it never appeared in the menu.
[URL=http://facepunch.com/showthread.php?t=1399673].. [/URL]
look into panel:SetPaintedManually() and panel:PaintManual()
Also you don't need that think hook check, just use panel:ParentToHUD()
Sorry, you need to Log In to post a reply to this thread.