SetTimer

From SA-MP Wiki

(Difference between revisions)
Jump to: navigation, search
Revision as of 04:43, 8 July 2012
Smithy (Talk | contribs)

← Previous diff
Revision as of 21:37, 4 February 2014
Connor Mead (Talk | contribs)

Next diff →
Line 1: Line 1:
{{Scripting}} {{Scripting}}
-{{Title}} 
{{Description|Sets a timer to call a function after some time.}} {{Description|Sets a timer to call a function after some time.}}
Line 37: Line 36:
[[Category:Scripting Functions]] [[Category:Scripting Functions]]
-[[ru:SetTimer]] 
[[de:SetTimer]] [[de:SetTimer]]
 +[[fr:SetTimer]]
 +[[ru:SetTimer]]

Revision as of 21:37, 4 February 2014



Description:

Sets a timer to call a function after some time.


Parameters:
(funcname[], interval, repeating)
funcname[]Name of the function to call as a string. Needs to be a public!
intervalInterval in milliseconds.
repeatingBoolean if the timer should occur repeatedly or only once


Return Values:

The ID of the timer that was started


Image:32px-Ambox_warning_orange.png

Note

Timer IDs are never used twice. You can use KillTimer() on a timer ID and it won't matter if it's running or not.


Image:32px-Circle-style-warning.png

Important
Note

The function that should be called, must be public, meaning it has to be forwarded.
Image:32px-Ambox_warning_orange.png

Note

The use of many timers will result in increased memory/cpu usage.


forward message();
 
public OnGameModeInit()
{
    print("Starting timer...");
    SetTimer("message", 1000, false); // Set a timer of 1000 miliseconds (1 second)
}
 
public message()
{
    print("1 second has passed.");
}

Related Functions

The following functions may be useful, as they are related to this function in one way or another.

In other languages