Timer delay problem

I use timer.Create (clientside) with a delay of 0.1 and infinite reps. Whenever I edit the 0.1 value in-game it uses the correct delay, whenever I keep 0.1 as value and restart the server it will completely ignore the delay and just spam as fast as it possibly can.
Something I did wrong? Something wrong with the timer? Let me know all help is appreciated.

EDIT:
Seems like whenever I use a hook to make it start after a certain event has happened (for example when a chat message pops up in chat, that means the timer gets created a good time after you joined the server) it does not spam as fast as it can but just use the regular delay.

If you want to use infinite “timers” with 0.1 delay i’d recommend instead using local variables, the

GM:Think hook, and using

CurTime/

RealTime together

In my case I have to use timers sadly. I’ll have to find a way to fix the 0.1 delay problem.

.1 = .1 of a second. It’s spamming it 10x per second. Are you sure that’s it’s not just doing what it’s told?

As I said whenever I update the LUA file it will correctly do it 10x a second, while when it creates the timer whenever the players is loaded it will do it every tick (default 66 times a second). The difference between 10 and 66 times is quite noticeable.

Maybe the file is being run multiple times and the timer is being created multiple times.

Tell us exactly what you’re trying to accomplish - there may be a better way to do it.

For example, I had someone ask me a similar question in order to remove a weapon from someone who picked it up and they used Tick / Think or timer when it could be accomplished using a hook which is called when the weapon is picked up ( not to mention the weapons can be deleted as soon as they are spawned ) and there are hooks that are called when the player switches to the weapon…

timers aren’t reliable from my experience - unless they have been corrected… Another way to accomplish having something run ~10 times per second would be to have a simple think hook:


//
// Think Hook to run something approx. 10 times per second...
//
local CFG_LogicInterval = 1 / 10; -- Interval in seconds, ie 10 times per second..
local __NextLogicTime = 0; -- Internal value - do not edit..
hook.Add( "Think", "Run~10xPerSecond", function( )
	// If the time-difference between the current time and our next-scheduled execute-logic-interval is 0 ( because tick is executed ~33 times per second by default, if 0 then time is up anyway ) or higher then execute the logic
	if ( CurTime( ) - __NextLogicTime >= 0 ) then
		// Update our clock... so it'll run the logic within 1 / 10 seconds from now...
		__NextLogicTime = CurTime( ) + CFG_LogicInterval;

		// Run the logic...
		-- print( "printing is expensive, don't do this unless debugging.." );
	end
end );


If timers have been fixed, then it should be fine - just remember if you’re running tests on your local SRCDS and you haven’t joined, you will need to join or have a bot join to let timers and CurTime / Time to start…

But, again, there may be a better way to whatever it is you’re trying to accomplish - why not explain what you’re trying to do - there may be better suggestions.

Hey, it’s you! Welcome back! We’ve missed you.

On topic: GalaxyBeatzz, I want to know more about the problem you’re having, can you please post your code?

Acecool: I know it’s against your style, but I really recommend that on the forums you use only “–” comments, because the syntax highlighter doesn’t acknowledge the “//” syntax :wink:

I have sort of fixed my problem by just letting the timer pause 10 seconds before starting, I guess timers require your client to be loaded for a while before starting them.

The purpose of the timer is to loop through frames, (basically an classic flip book animation) creating the illusion of movement. That’s really all there is, after having played it will pause the timer for a few seconds and then it will unpause and do its thing again.

Glad you fixed it, I still want to see the code though (both broken and fixed). “I guess timers require your client to be loaded for a while before starting them.” – I never heard of an issue with this, which is why I want to see the code that had problems.