Squirrel/Functions/Timers/NewTimer

From Liberty Unleashed Wiki
(Difference between revisions)
Jump to: navigation, search
(Example2)
(Example2)
 
(One intermediate revision by one user not shown)
Line 26: Line 26:
 
== Example2 ==
 
== Example2 ==
  
This will start a timer saying ''BOO!'' 3 times every 5 seconds when a player joins
+
This will start a timer Giving The Player 2000$ 1 time when a player joins After 5 Sec.
  
 
<code lang="squirrel">
 
<code lang="squirrel">

Latest revision as of 14:17, 10 August 2013

Home   |   Squirrel Scripting   |   Server Functions   |   Server Events   |   Client Functions   |   Client Events

This function creates a new timer.

[edit] Syntax

  1. Timer NewTimer( string function, int interval, int repeat, args... )

[edit] 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

[edit] Example1

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.  

[edit] Example2

This will start a timer Giving The Player 2000$ 1 time when a player joins After 5 Sec.

  1.  
  2. function onPlayerJoin( player )
  3. {
  4. NewTimer( "Cash", 5000, 1, player );
  5. }
  6.  
  7. function Cash( player )
  8. {
  9. player.Cash += 2000;
  10. }
  11.  

[edit] Notes

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

[edit] Related Functions

Personal tools
Namespaces

Variants
Actions
Navigation
scripting
Toolbox