Squirrel/Functions/Timers/NewTimer
From Liberty Unleashed Wiki
(Difference between revisions)
(→Example) |
(→Notes) |
||
Line 14: | Line 14: | ||
== Example1 == | == Example1 == | ||
+ | |||
+ | This will start a timer saying ''BOO!'' 3 times every 5 seconds when a player joins | ||
+ | |||
+ | <code lang="squirrel"> | ||
+ | function onPlayerJoin( player ) | ||
+ | { | ||
+ | NewTimer( "MessagePlayer", 5000, 3, "BOO!", player ); | ||
+ | } | ||
+ | </code> | ||
+ | |||
+ | == Example2 == | ||
This will start a timer saying ''BOO!'' 3 times every 5 seconds when a player joins | This will start a timer saying ''BOO!'' 3 times every 5 seconds when a player joins |
Revision as of 14:13, 10 August 2013
This function creates a new timer.
Syntax
Timer NewTimer( string function, int interval, int repeat, args... )
Arguments
- function - This is the function the timer will call
- interval - The interval the timer will fire at in milliseconds
- repeat - How many times the function will repeat (0 is infinate)
- args - Any arguments you want to pass to the function when called
Example1
This will start a timer saying BOO! 3 times every 5 seconds when a player joins
function onPlayerJoin( player ) { NewTimer( "MessagePlayer", 5000, 3, "BOO!", player ); }
Example2
This will start a timer saying BOO! 3 times every 5 seconds when a player joins
function onPlayerJoin( player ) { NewTimer( "MessagePlayer", 5000, 3, "BOO!", player ); }
Notes
The function MessagePlayer and call onPlayerJoin were used in in this example. More info about them in corresponding pages.
Related Functions
- NewTimer
- Timer.Delete
- Timer.Start
- Timer.Stop