• Putting draw.SimpleText outside of hook.
    3 replies, posted
Ive been playing with draw.SimpleText for some time now, ive been wanting it to be visible for few seconds and then disappear, i got it to work with the HUDPaint hook, but it does not fit my needs, i currently have function DrawRandomText(text,font,color) local show = 1 local Scrh = math.random(-30,30) local Scrw = math.random(-30,30) hook.Add("HUDPaint","CenterScreenText",function() if show == 1 then draw.SimpleText(text, font, ScrW() / 2 + Scrw, ScrH() / 2 + Scrh, color,TEXT_ALIGN_CENTER,TEXT_ALIGN_CENTER ) end timer.Simple(0.5,function()show=0 end) end) end    is the a more effective way of doing this so i could see multiple draw.simpletext?
timer in HUDPaint or in any other render/think function is a sin. At least place this timer outside the hook
Thanks
local randomTexts = {} local hookRemoved = true function DrawRandomText(text, font, size, time)     if !time then time = 2 end     local i = table.insert(randomTexts, {text = text, font = font, size = size})     if hookRemoved then         hook.Add(“HUDPaint”, “DrawRandomTexts”, function()             for k, v in  ipairs(randomTexts) do                 local text, font, size = v.text, v.font, v.size                 — draw here             end         end)         hookRemoved = false     end     timer.Simple(time, function()         randomTexts[i] = nil         if #randomTexts == 0 then             hook.Remove(“HUDPaint”, “DrawRandomText”)             hookRemoved = true         end     end) end
Sorry, you need to Log In to post a reply to this thread.