Advertisement
GustavoAraujo

Timer Manager

Sep 2nd, 2012
334
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 1.16 KB | None | 0 0
  1. #define MAX_TIMERS 50
  2.  
  3. new bool:_Repetir[MAX_TIMERS];
  4. new bool:_IniciouTimer[MAX_TIMERS];
  5. new _Tempo[MAX_TIMERS];
  6. new _TempoPassado[MAX_TIMERS];
  7. new Func[MAX_TIMERS][128];
  8.  
  9. stock StartTimer(Func_[],Tempo_,&Timerid_,bool:Repetir_ = false)
  10. {
  11.     Timerid_ = SetTimer(Func_,Tempo_,Repetir_);
  12.     SetTimerEx("Acabou",Tempo_,false,"d",Timerid_);
  13.     _Tempo[Timerid_] = Tempo_;
  14.     _TempoPassado[Timerid_] = GetTickCount();
  15.     format(Func[Timerid_],128,"%s",Func_);
  16.     _IniciouTimer[Timerid_] = true;
  17.     return 1;
  18. }
  19. stock GetTimer(Timerid_)
  20. {
  21.     if(_IniciouTimer[Timerid_] == true) return _Tempo[Timerid_] - (GetTickCount() - _TempoPassado[Timerid_]);
  22.     return -1;
  23. }
  24. stock StopTimer(Timerid_)
  25. {
  26.     _Tempo[Timerid_] = GetTimer(Timerid_);
  27.     KillTimer(Timerid_);
  28.     return 1;
  29. }
  30. stock KillTimerEx(Timerid_)
  31. {
  32.       KillTimer(Timerid_);
  33.       _Tempo[Timerid_] = 0;
  34.       Func[Timerid_][0] = '\0';
  35.       _IniciouTimer[Timerid_] = false;
  36. }
  37. stock ContinueTimer(Timerid_)
  38. {
  39.     if(_Tempo[Timerid_] == 0) return 0;
  40.     if(_IniciouTimer[Timerid_] == true) return 0;
  41.     StartTimer(Func[Timerid_],_Tempo[Timerid_],Timerid_,_Repetir[Timerid_]);
  42.     return 1;
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement