Squirrel/Functions/Timers/NewTimer

From Liberty Unleashed Wiki
(Difference between revisions)
Jump to: navigation, search
Line 1: Line 1:
 
__NOTOC__
 
__NOTOC__
This creates a new timer
+
This function creates a new timer.
  
 
== Syntax ==
 
== Syntax ==
  
<code>timer NewTimer( string function, int interval, int repeat, args... )</code>
+
<code>Timer NewTimer( string function, int interval, int repeat, args... )</code>
  
 
== Arguments ==
 
== Arguments ==
  
* '''function''' This is the function the timer will call
+
* '''function''' - This is the function the timer will call
* '''interval''' The interval the timer will fire at in milliseconds
+
* '''interval''' - The interval the timer will fire at in milliseconds
* '''repeat''' How many times the function will repeat (0 is infinate)
+
* '''repeat''' - How many times the function will repeat (0 is infinate)
* '''args''' Any arguments you want to pass to the function when called
+
* '''args''' - Any arguments you want to pass to the function when called
  
 
== Example ==
 
== Example ==
Line 18: Line 18:
  
 
<code lang="squirrel">
 
<code lang="squirrel">
function OnPlayerJoin( id )
+
function onPlayerJoin( player )
 
{
 
{
     NewTimer( "MessagePlayer", 5000, 3, "BOO!", id );
+
     NewTimer( "MessagePlayer", 5000, 3, "BOO!", player );
 
}
 
}
 
</code>
 
</code>
Line 26: Line 26:
 
=== Notes ===
 
=== Notes ===
  
The function [[Squirrel/Functions/Misc/MessagePlayer|MessagePlayer]] and call [[Squirrel/Events/Player/OnPlayerJoin|OnPlayerJoin]] were used in in this example. More info about them in corresponding pages.
+
The function [[Squirrel/Server/Functions/Messages/MessagePlayer|MessagePlayer]] and call [[Squirrel/Server/Events/Player/onPlayerJoin|onPlayerJoin]] were used in in this example. More info about them in corresponding pages.
  
 
== Related Functions ==
 
== Related Functions ==
  
 
{{Squirrel/Functions/Timers}}
 
{{Squirrel/Functions/Timers}}

Revision as of 09:54, 28 November 2009

This function creates a new timer.

Syntax

  1. 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

Example

This will start a timer saying BOO! 3 times every 5 seconds when a player joins

  1.  
  2. function onPlayerJoin( player )
  3. {
  4. NewTimer( "MessagePlayer", 5000, 3, "BOO!", player );
  5. }
  6.  

Notes

The function MessagePlayer and call onPlayerJoin were used in in this example. More info about them in corresponding pages.

Related Functions

Personal tools
Namespaces

Variants
Actions
Navigation
scripting
Toolbox