Squirrel/Functions/Timers/NewTimer

From Liberty Unleashed Wiki
(Difference between revisions)
Jump to: navigation, search
Line 18: Line 18:
  
 
<code lang="squirrel">
 
<code lang="squirrel">
function OnPlayerJoin( id, name )
+
function OnPlayerJoin( id )
 
{
 
{
 
     NewTimer( "MessagePlayer", 5000, 3, "BOO!", id );
 
     NewTimer( "MessagePlayer", 5000, 3, "BOO!", id );

Revision as of 03:44, 28 February 2009

This 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( id )
  3. {
  4. NewTimer( "MessagePlayer", 5000, 3, "BOO!", id );
  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