• Avatar on HUD
    8 replies, posted
Hello there, I'm a beginner at LUA and wanted to write my own HUD. I also made a convar to disable the HUD and use the default if preferred. I already got everything working, except for the Avatar. I have 2 problems with the avatar. The first one is that it doesn't load the image but a blue questionmark instead. The second problem is that when i disable my HUD the avatar stays and doesn't go away unless I restart the map. Can someone tell me what i'm doing wrong here? I'd really apprechiate it. https://files.facepunch.com/forum/upload/436404/ad452ccc-a3f0-49a0-891b-b4a647bbc2bb/un1.png This is the avatar on my HUD it shows the blue questionmark instead of my steam profile picture. https://files.facepunch.com/forum/upload/436404/282fda77-7431-416e-8fd6-404708698bb9/un2.png This happens when I disable my HUD. https://files.facepunch.com/forum/upload/436404/85f977ea-a654-4f8f-8c09-6977b489ea30/un3.jpg This is the code.
you have to remove the avatar - in this case Avatar:Remove()
Didn't worked. It still persists on the screen with a blue questionmark. https://files.facepunch.com/forum/upload/436404/8f5fee95-04c4-4ce0-b76f-1a60798ca067/{9CD65B1E-DDF0-4B66-B651-7FAB7A16F9C3}.png.jpg If i remove the if else condition the avatar isn't shown at all. But when I remove the Avatar:Remove() the avatar reappears but this time with my steam profile picture as intended.
The problem is that you create an avatar each frame (if it's a Paint hook) and you override "Avatar" the next frame. So it just removes the last created object. local Avatar -- make it local function your_draw_func( ... ) if !Avatar and blackhud:GetBool() then -- create avatar here elseif IsValid(Avatar) and !blackhud:GetBool() then Avatar:Remove() end end Try that, no clue if my logic is correct there - I am pretty tired. But I hope you get what I mean.
Well, at least that solved the problem the Avatar won't render when joined. Thank you! Now the blue questionmark is gone and my steam profile picture finally appears. However the Avatar still doesn't go avay when I disable my HUD or switch to the camera. It only disappears when going in the escape menu. https://files.facepunch.com/forum/upload/436404/37bbac3b-fffc-4b31-a5dc-785c0459ac6d/adsdda.png Finally an avatar when joining. https://files.facepunch.com/forum/upload/436404/527dce97-89a8-40bf-b50a-2aba8801c6b1/asddsda.png But still doesn't wanna go away when my HUD is disabled. https://files.facepunch.com/forum/upload/436404/c1a0e63a-9fe5-4786-a520-a98d3bade543/fasdfdfd.png.jpg I even tried to put "Avatar:Remove()" into the function that hides the old HUD but that gave me lua errors. [ERROR] addons/blackhud/lua/autorun/client/blackhud.lua:265: attempt to index upvalue 'Avatar' (a nil value)   1. nextevent - addons/blackhud_1674592152/lua/autorun/client/blackhud.lua:265    2. unknown - lua/dlib/modules/hook.lua:1067
But I noticed something interesting. I tried to move the avatar upwards and it seems like the avatar gets somewhat baked onto the HUD. It doesnt remove the previous one but it places a new one over it. I tried it several times until I disabled my HUD. When my HUD was disabled I couldn't place a new Avatar anymore. So the code must be working but I can't find a way to get rid of the avatars that got baked onto the HUD. https://files.facepunch.com/forum/upload/436404/69336141-2962-4987-91d2-8bd63cb948bd/Unbenannt.png
https://files.facepunch.com/forum/upload/436404/dfb968b0-f3f6-4cbb-aad3-c6ec7ea5c640/{FD06D2B8-E798-4771-AE62-6ED1D8E4CB42}.png Okay, I got the avatar fully working. It displays when my HUD is enabled and hides when my HUD is disabled. I had to make a workaraund for the camera though. But now everytime a game loads or a player joins a server that has this HUD, he receives a LUA error: [ERROR] addons/blackhud_1674592152/lua/autorun/client/blackhud.lua:1: attempt to index upvalue 'h' (a nil value) 1. v - addons/blackhud_1674592152/lua/autorun/client/blackhud.lua:1 2. unknown - lua/includes/modules/hook.lua:84 Seems to be the Avatar local that hasn't a value but it needs to be that way or else the avatar gets broken again... Any ways to fix it?
You could use this lib to DRAW (!) this avatar. It's originally made by Bull and fixed & improved by myself: TTT2/b
Thanks. I got it working now.
Sorry, you need to Log In to post a reply to this thread.