Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define MAX_TIMERS 10
- #define TIMERS_UPDATE 100
- forward TOnGameModeInit();
- forward UpdateTimers();
- new TimerTime[MAX_TIMERS], TimerInterval[MAX_TIMERS], TimerRepeating[MAX_TIMERS];
- new TimerName[MAX_TIMERS][75];
- public OnGameModeInit()
- {
- SetTimer("UpdateTimers", TIMERS_UPDATE, 1);
- return CallLocalFunction("TOnGameModeInit", "");
- }
- public UpdateTimers()
- {
- new GetTime = GetTickCount();
- for(new A; A != MAX_TIMERS; A++)
- {
- if(!TimerTime[A]) continue;
- if(TimerTime[A] <= GetTime)
- {
- if(!TimerRepeating[A]) TimerTime[A] = 0;
- else TimerTime[A] = GetTime+TimerInterval[A];
- CallLocalFunction(TimerName[A], "");
- }
- }
- return 1;
- }
- stock TSetTimer(funcname[], interval, repeating)
- {
- for(new A; A != MAX_TIMERS; A++)
- {
- if(TimerTime[A] != 0) continue;
- strmid(TimerName[A], funcname, 0, strlen(funcname));
- TimerInterval[A] = interval;
- TimerTime[A] = GetTickCount()+interval;
- TimerRepeating[A] = repeating;
- return A;
- }
- return -1;
- }
- stock KillTimerEx(timerid) TimerTime[timerid] = 0;
- #define SetTimer TSetTimer
- #if defined _ALS_OnGameModeInit
- #undef OnGameModeInit
- #else
- #define _ALS_OnGameModeInit
- #endif
- #define OnGameModeInit TOnGameModeInit
Advertisement
Add Comment
Please, Sign In to add comment