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], bool: 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(const funcname[], const interval, bool: 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 + MAX_TIMERS + 1);
- }
- return -1;
- }
- stock KillTimerEx(timerid)
- {
- if(timerid < -1) return TimerTime[- (timerid - MAX_TIMERS - 1)] = 0;
- return KillTimer(timerid);
- }
- #define SetTimer TSetTimer
- #define KillTimer KillTimerEx
- #if defined _ALS_OnGameModeInit
- #undef OnGameModeInit
- #else
- #define _ALS_OnGameModeInit
- #endif
- #define OnGameModeInit TOnGameModeInit
Advertisement
Add Comment
Please, Sign In to add comment