SHOW:
|
|
- or go back to the newest paste.
| 1 | #define MAX_TIMERS 10 | |
| 2 | #define TIMERS_UPDATE 100 | |
| 3 | ||
| 4 | forward TOnGameModeInit(); | |
| 5 | forward UpdateTimers(); | |
| 6 | ||
| 7 | new TimerTime[MAX_TIMERS], TimerInterval[MAX_TIMERS], TimerRepeating[MAX_TIMERS]; | |
| 8 | new TimerName[MAX_TIMERS][75]; | |
| 9 | ||
| 10 | public OnGameModeInit() | |
| 11 | {
| |
| 12 | SetTimer("UpdateTimers", TIMERS_UPDATE, 1);
| |
| 13 | return CallLocalFunction("TOnGameModeInit", "");
| |
| 14 | } | |
| 15 | ||
| 16 | public UpdateTimers() | |
| 17 | {
| |
| 18 | - | new GetTime = GetTickCount(); |
| 18 | + | |
| 19 | {
| |
| 20 | if(!TimerTime[A]) continue; | |
| 21 | if(TimerTime[A] <= GetTickCount()) | |
| 22 | - | if(TimerTime[A] <= GetTime) |
| 22 | + | |
| 23 | if(!TimerRepeating[A]) TimerTime[A] = 0; | |
| 24 | else TimerTime[A] = GetTickCount()+TimerInterval[A]; | |
| 25 | - | else TimerTime[A] = GetTime+TimerInterval[A]; |
| 25 | + | |
| 26 | } | |
| 27 | } | |
| 28 | return 1; | |
| 29 | } | |
| 30 | ||
| 31 | stock TSetTimer(funcname[], interval, repeating) | |
| 32 | {
| |
| 33 | for(new A; A != MAX_TIMERS; A++) | |
| 34 | {
| |
| 35 | if(TimerTime[A] != 0) continue; | |
| 36 | strmid(TimerName[A], funcname, 0, strlen(funcname)); | |
| 37 | TimerInterval[A] = interval; | |
| 38 | TimerTime[A] = GetTickCount()+interval; | |
| 39 | TimerRepeating[A] = repeating; | |
| 40 | return A; | |
| 41 | } | |
| 42 | return -1; | |
| 43 | } | |
| 44 | ||
| 45 | stock KillTimerEx(timerid) TimerTime[timerid] = 0; | |
| 46 | ||
| 47 | #define SetTimer TSetTimer | |
| 48 | ||
| 49 | #if defined _ALS_OnGameModeInit | |
| 50 | #undef OnGameModeInit | |
| 51 | #else | |
| 52 | #define _ALS_OnGameModeInit | |
| 53 | #endif | |
| 54 | #define OnGameModeInit TOnGameModeInit |