Timers

They completely confuse me, they confused me when I learnt E2 and I don’t get them at all in Lua either, It’d be awesome if one of you helpful people could explain it to me? Thanks in advance.

[lua]timer.Simple( 3, function()
– code here
end )[/lua]

Once this is called, 3 seconds later, whatever is inside the function will be executed

Or you could use a more advanced timer:
[lua]timer.Create(“Test Timer”, 3, 0, function()
– Code here.
end)
– This will create a timer called “Test Timer” that will execute the function an infinite number of times every 3 seconds.

timer.Create(“Test Timer2”, 5, 2, function()
– Code here.
end)
– This will create timer “Test Timer2” that will execute the function after 5 seconds then again after another 5 seconds.
– A total of 2 executions.
[/lua]

And then use functions such as:
[lua]timer.Pause(“Test Timer”) – Pause the timer “Test Timer”.
timer.UnPause(“Test Timer”) – Unpause the timer “Test Timer”.

timer.Stop(“Test Timer2”) – Stop the timer “Test Timer2”.
timer.Start(“Test Timer2”) – Start the timer “Test Timer2”.
[/lua]

To control the timer.

Go to **[this page

http://wiki.garrysmod.com/favicon.ico](http://wiki.garrysmod.com/?title=Timer)** to see more functions for timers.

First of all, to check you know how a timer works ( this is what I did and moved on from it ) is create it so if a players health is less than 100 ( default starting health ) then he gains 1 HP per <insert number here> second(s)

Then go on from there to create more advanced timers!