• A timer placed on a players HUD?
    3 replies, posted
Hello again, I am making a basic gamemode and I just want to place a timer on the HUD but I cant get the thing to update. Here is my code: shared.lua [code] ROUND_BREAK = 10 ROUND_TIME = 30 ROUND_REMAININGTIME = 30 function RoundStart() timer.Create("RoundTime", ROUND_TIME, ROUND_TIME, function() ROUND_REMAININGTIME = ROUND_REMAININGTIME - 1 end ) if ROUND_REMAININGTIME >1 then RoundEnd() end end function RoundEnd() for _, ply in ipairs( player.GetAll() ) do ply:Freeze( true ) end timer.Create("RoundBreak", ROUND_BREAK, 1, function() MapVote.Start() end ) end RoundStart() //-start the round [/code] cl_init.lua [code] include("shared.lua") surface.CreateFont( "TimerFont", { font = "Arial", size = 42, weight = 500, blursize = 0, scanlines = 0, antialias = true, underline = false, italic = false, strikeout = false, symbol = false, rotary = false, shadow = false, additive = false, outline = true, } ) function GM:HUDPaint() self.BaseClass:HUDPaint() surface.SetTextColor(255, 0, 0, 255) surface.SetTextPos(20,20) surface.SetFont("TimerFont") surface.DrawText(ROUND_REMAININGTIME) end [/code]
Next Update Changelog [url]https://docs.google.com/document/d/1fmulYVtXga8tlbkbuJDMbHn-xzh1P7VjTjTHgNh2ABg/edit#heading=h.hppea3cme4uo[/url] Added timer.TimeLeft(name) and timer.RepsLeft(name) Alternatively, you could use a CurTime( ) system where you set the time the round is to expire and subtract the current from that expiry time, then format it nicely and display it.
[QUOTE=Acecool;44267999]Next Update Changelog [url]https://docs.google.com/document/d/1fmulYVtXga8tlbkbuJDMbHn-xzh1P7VjTjTHgNh2ABg/edit#heading=h.hppea3cme4uo[/url] Added timer.TimeLeft(name) and timer.RepsLeft(name) Alternatively, you could use a CurTime( ) system where you set the time the round is to expire and subtract the current from that expiry time, then format it nicely and display it.[/QUOTE] /thread I solved it. I just did [code] math.Round(ROUND_TIME - CurTime()) [/code] Thanks Acecool! But to be honest I found the work around with some in depth googling! At first I did with system.uptime() and realized how horribly wrong that was and found about CurTime() later. Now I ran into this: [url]http://facepunch.com/showthread.php?t=1376928&p=44268972#post44268972[/url]
He solved the issue on the above thread^, dont think he needs any help now.
Sorry, you need to Log In to post a reply to this thread.