I am making a HUD timer with this piece of code:
[CODE]hook.Add( "HUDPaint", "drawroundtext", function()
local roundtimer = timer.TimeLeft( "RoundTimer" )
local timeleft = tostring( roundtimer )
surface.SetFont( "CloseCaption_Bold" )
surface.SetTextColor( 255, 255, 255, 255 )
surface.SetTextPos( ScrW()/2, 0 )
surface.DrawText( timeleft )
end )[/CODE]
But when I actually ge into GMod all it shows is nil.
Here is the timer code if you need it:
[CODE]timer.Create( "RoundTimer", 600, 0, function()
for k,v in pairs(player.GetAll()) do
v:Kill()
end
game.CleanUpMap( false , { "ctf_flag" , "info_player_red" , "info_player_blue" } )
end)[/CODE]
Thankyou for any help
Probably because the RoundTimer timer is serverside.
[editline]17th May 2014[/editline]
Your best bet is not to use a timer, but to use CurTime() -RoundStartTime to get the seconds since the round has started. You can set the RoundStartTime by sending the client a net message when the round starts.
Meh, too much work. Just moved timer to shared and removed the commands, then copied and pasted the timer back to init and renamed, works fine now. Thanks for serverside tip.
Sorry, you need to Log In to post a reply to this thread.