Guest User

a

a guest
Apr 13th, 2013
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 1.19 KB | None | 0 0
  1. #define MAX_TIMERS 10
  2. #define TIMERS_UPDATE 100
  3.  
  4. forward TOnGameModeInit();
  5. forward UpdateTimers();
  6.  
  7. new TimerID;
  8. new TimerTime[MAX_TIMERS], TimerInterval[MAX_TIMERS], TimerRepeating[MAX_TIMERS];
  9. new TimerName[MAX_TIMERS][75];
  10.  
  11. public OnGameModeInit()
  12. {
  13.     SetTimer("UpdateTimers", TIMERS_UPDATE, 1);
  14.     return CallLocalFunction("TOnGameModeInit", "");
  15. }
  16.  
  17. public UpdateTimers()
  18. {
  19.     new GetTime = GetTickCount();
  20.     for(new A; A != MAX_TIMERS; A++)
  21.     {
  22.         if(!TimerTime[A]) continue;
  23.             if(TimerTime[A] <= GetTime)
  24.             {
  25.                     if(!TimerRepeating[A]) TimerTime[A] = 0;
  26.             else TimerTime[A] = GetTime+TimerInterval[A];
  27.                     CallLocalFunction(TimerName[A], "");
  28.         }
  29.     }
  30.     return 1;
  31. }
  32.  
  33. stock TSetTimer(funcname[], interval, repeating)
  34. {
  35.     strmid(TimerName[TimerID], funcname, 0, strlen(funcname));
  36.     TimerInterval[TimerID] = interval;
  37.     TimerTime[TimerID] = GetTickCount()+interval;
  38.     TimerRepeating[TimerID] = repeating;
  39.     return TimerID++;
  40. }
  41.  
  42. stock KillTimerEx(timerid) TimerInterval[timerid] = 0;
  43.  
  44. #define SetTimer TSetTimer
  45.  
  46. #if defined _ALS_OnGameModeInit
  47.     #undef OnGameModeInit
  48. #else
  49.     #define _ALS_OnGameModeInit
  50. #endif
  51. #define OnGameModeInit TOnGameModeInit
Advertisement
Add Comment
Please, Sign In to add comment