timers completely broken

Hey guys,

I’ve been experiencing some problems with timers in lua and I have no idea what to do about it. The issue seems to be that the timers functions don’t do anything at all (including creating an error), regardless of what function or delay I put on them.

I ran some tests in the server console using lua_run and here’s what came up:


lua_run timer.Simple(1, function() print('hi') end);
> timer.Simple(1, function() print('hi') end)...
lua_run print('hi')
> print('hi')...
hi
lua_run function print_hi() print('hi') end
> function print_hi() print('hi') end...
lua_run print_hi()
> print_hi()...
hi
lua_run timer.Simple(1, print_hi);                  
> timer.Simple(1, print_hi)...
lua_run timer.Simple( 5, function() print( "Hello World" ) end )
> timer.Simple( 5, function() print( "Hello World" ) end )...
lua_run timer.Simple( 5, function() print( "Hello World" ) end )
> timer.Simple( 5, function() print( "Hello World" ) end )...


Am I doing anything wrong, or is this an issue with Garry’s Mod itself?

Thanks,
Monodop

Quotation marks don’t do well in the console. If timers didn’t work your game would be entirely fucked up, trust me.

These same issues occurred when running similar code through lua scripts, so I’m thinking running from console might not be the issue.

Yeah I Just saw that you did “print( ‘hi’ )” in the console, I missed that part. Dunno, might be a conflict. What addons do you have?

I disabled all of the addons except for the TTT Jihad weapon from the Steam Workshop (though this was installed directly into the gamemode). The server is also running in the terrortown gamemode.

This is because timers don’t tick when you are in menu in singleplayer. Go ingame for 5 sec and all the times will tick again.

These tests were called in the srcds dedicated server. Could it be that there were no players on? Maybe the wiki should mention that if its the case.

Timers use the “Think” hook, if no players have joined at least once since it was last restarted then your timers won’t run because the “Think” hook doesn’t start until then.

Yeah that’s it. Servers are basically frozen when no players are on, which is why your timers aren’t working.

Okay. Thank you guys for the quick replies; I appreciate your help!