hook.Remove("HUDPaint", "name") in a timer makes the material flickering?
2 replies, posted
So i have this simple function to let a material be on the players screen, and after 5 seconds dissapear again
local function falldmg()
hook.Add("HUDPaint", "Assistantfalldmg", function()
local fall = Material( "falldamage.vmt" )
surface.SetMaterial( fall )
surface.SetDrawColor( 255, 255, 255 )
surface.DrawTexturedRect( 20, ScrH()/2, 200, 100 )
end)
timer.Simple(5,function() hook.Remove("HUDPaint", "Assistantfalldmg") end)
end
when theres no timer it never gets shown, since the hook gets created and instantly gets removed again. Makes sense...but when i put it in a timer to 5 seconds so the material dissapears after 5 seconds, what happens instead is that the material starts flickering as if would fight about being drawn or not drawn...its really weird and i dont know why?
On a other addon i already did the same, make a HUDPaint element, and remove it after a certain time with a timer. And it worked fine. Both materials are VTF files, both are animated. All the same. (the one that worked and this problem now) So what the hell is going on?
Where are you calling `falldmg`.
Oh lol. Your question was the answer XD To answer your question i wanted to copy paste the moment the function gets called. I noticed that this whole thing was still in a HUDPaint hook, which i had there in a older version. Forgot to remove it..the one hook started the falldmg() the whole time, while the over removed it self. Which resulted in the flickering/fighting if it stays or not...alright i feel retarted now..but i also probably would never have realized if i wouldnt have checked again..
Sorry, you need to Log In to post a reply to this thread.