timer.Create

From GMod Wiki

Jump to: navigation, search
Function
Syntax timer.Create( Var uniqueID, Float delay, Integer reps, Function func, Var ... arguments )
Where is this used?
Description:

Creates a timer that runs a function with the given arguments when it expires.

"reps" can be either the number of times the timer will run, or 0 if the timer will run forever.
Returns: nil
Part of Library: Timer
Realm: NewerShared.png
BBCode Link: [b][url=http://wiki.garrysmod.com/?title=Timer.Create]Timer.Create [img]http://wiki.garrysmod.com/favicon.ico[/img][/url][/b]



Examples

DescriptionDisplays "Test" in the console once after 10 seconds.
Used onNewerShared.png
Code
 
timer.Create("timer1", 10, 1, MsgN, "Test")
 
Output(After 10 seconds has elapsed) "Test"


DescriptionDisplays "Hi!" in the console every 10 seconds forever.
Used onNewerShared.png
Code
 
timer.Create( "my_timer", 10, 0, function()
	MsgN("Hi!")
end)
 
Output(Every 10 seconds) "Hi!"


DescriptionCreates a timer that will set fire to a player once after 5 seconds, with extra parameters.
Used onNewerServer.png
Code
 
function Ignited( ply )
       ply:Ignite(3,0)
end
timer.Create( "Atimer", 5, 1, Ignited, ply )
 
OutputNone


Additional Notes

See Also

Personal tools
Namespaces
Variants
Actions
Navigation
Lua Scripting
Functions
Hooks
Toolbox