• Check the timer.
    12 replies, posted
I have a timer for a gamemode that will switch the teams every 140 seconds. Is there a way to check the timer and return a string, just so that i can show the time left. I can work out the HUD from there.
Set a value when you start the timer or on every iteration and use CurTime to check the time since that var
So, Theoretically, This? [CODE]function StartTimer() timer.Create("MatchTime", 240, 0, ShowTimer(CurTime( ))) end function ShowTimer() local Start = arg[1] local End = (Start + 240) If CurTime( ) = End then Switch() end end[/CODE]
If your wanting to show the time updated every second you need to use a think hook.
Well I did this, and it only made it go to base gamemode. [CODE]function StartTimer() timer.Create("MatchTime", 240, 0, ShowTimer) end function ShowTimer() local Start = CurTime( ) local RoundEnd = (Start + 240) If (CurTime( ) = RoundEnd) then Switch() end end hook.Add( "Think", "ShowTheTimer", ShowTimer)[/CODE]
You capitalized your If.
Thanks, but that didn't appear to be the problem.
You are using = instead of == to check for equality.
Crazy, I dedicate this to you.... [url]http://theendofinternets.ytmnd.com/[/url]
:confused: That's just silly.
[QUOTE=Crazy Quebec;21340967]:confused: That's just silly.[/QUOTE] People are finding more abstract ways to thank you now.
I wasn't sure if it's a bad or a good thing. :smile:
Nothing bad, I was just feeling a bit artsy.
Sorry, you need to Log In to post a reply to this thread.