SetTimerEx
Description
Sets a timer to call a function after the specified interval. This variant ('Ex') can pass parameters (such as a player ID) to the function.
Name | Description |
---|---|
funcname[] | The name of a public function to call when the timer expires. |
interval | Interval in milliseconds (1 second = 1000 MS). |
repeating | Boolean (true/false (or 1/0)) that states whether the timer should be called repeatedly (can only be stopped with KillTimer) or only once. |
format[] | Special format indicating the types of values the timer will pass. |
{Float,_}:... | Indefinite number of arguments to pass (must follow format specified in previous parameter). |
Returns
The ID of the timer that was started. Timer IDs start at 1 and are never reused. There are no internal checks to verify that the parameters passed are valid (e.g. duration not a minus value). Y_Less' 'fixes2' plugin implements these checks and also vastly improves the accuracy of timers, and also adds support for array/string passing.
Examples
Notes
tip
Timer ID variables should be initialized to -1 when they can to minimise the chance of accidentally killing timer ID 0 by mistake (or use timer ID 0 up at the start of OnGameModeInit). Timer intervals are not accurate (roughly 25% off). There are fixes available here and here. The function to be called must be public. That means it has to be forwarded.
Related Functions
- SetTimer: Set a timer.
- KillTimer: Stop a timer.
- CallLocalFunction: Call a function in the script.
- CallRemoteFunction: Call a function in any loaded script.