05.03.2018, 16:13 
	(
 Last edited by KashCherry; 13/01/2020 at 07:53 PM.
)
	
	Timer Fix v1.1.1
Description
This plugin makes timers more accurate
Natives
PHP Code:
/*
 * Replacement for a standart native function that includes additional parameters.
 * delay - the delay before the timer starts.
 * count - count of executions.
 */
native SetCustomTimer(funcname[], interval, delay, count);
/*
 * The same function but with argument passing.
 */
native SetCustomTimerEx(funcname[], delay, count, const format[], {Float,_}:...);
native KillAllTimers();
native IsValidTimer(timerid);
native GetTimerInterval(timerid);
native SetTimerInterval(timerid, interval);
native GetTimerRemainingTime(timerid);
/*
 * Stops the timer but doesn't delete it.
 * Use the ContinueTimer() to start it again.
 * Note: the callback will execute after the time remaining before the call.
 */
native PauseTimer(timerid);
/*
 * Continues the timer after pausing.
 */
native ContinueTimer(timerid);
/*
 * Adds the custom callback for timer.
 * For example:
 * new a = SetTimer("function_1");
 * AddTimerHandler(a, "function_2");
 * The timer will execute both callbacks.
 *
 * Note: arguments will also be passed to both functions.
 */
native AddTimerHandler(timerid, handler[]);
/*
 * Removes the added handler.
 */
native RemoveTimerHandler(timerid, handler[]); 
PHP Code:
#include <timerfix>
new num = 0;
new timer;
main() {
  timer = SetTimer("callback",1000,true)
}
forward callback();
public callback() {
  if(++num >= 5) {
    if(IsValidTimer(timer)) KillTimer(timer);
    SetTimerEx("callbackEx",1000,false,"d",num);
  }
}
forward callbackEx(num);
public callbackEx(num) {
  printf("Num: %d",num);
  KillAllTimers();
} 
Binaries(Windows, Linux)
Source code


