Documentation
IPS_SetScriptTimer
bool IPS_SetScriptTimer (int $ScriptID, int $TimerValue)
Parameters
| ScriptID | ID of the script |
| TimerValue | Time in seconds in which the script is called cyclically |
Returns
If the function succeeds, it returns TRUE, otherwise FALSE.
Description
This function sets the start value of the script timer of the script with the ID ScriptID to TimerValue. The value defines the time in seconds. The timer from the script counts down from the start value in steps of seconds. When the timer reaches 0 the script is executed and the script timer is reset to the start value. This process is repeated until the timer is explicitly deactivated. A timer is deactivated by setting the start value to 0. Negative values are treated like 0.
The duration of the timer can only be set on an exact second value if the timer value is 3600 or less. For values above 3600, irregularities can occur, depending on start time and/or divisor as the script timer shares the same limitations as normal cyclic events and their time templates. E.g., if a timer is set to 5 hours at 6:00, it triggers at 6:00, 11:00, 16:00, 21:00, and 1:00, even though 2:00 could have been expected.
TimerValue must be less than 86400 (one day). For larger values the function fails with "Interval must be less than 86400 seconds (1 day). Use a cyclic event for longer intervals" and the existing timer stays unchanged. Use a cyclic event for longer intervals, see IPS_SetEventCyclic.
Example
// The script is run every 10 seconds
IPS_SetScriptTimer($ScriptID, 10);