Advertisement
JeffryUGP

Race-Timer (Upcounting, 99.9% accurate)

Feb 18th, 2013
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 1.23 KB | None | 0 0
  1. //At top of your script.
  2. new Race_TimeCounter = -1;
  3. new Text:Race_TD;
  4.  
  5.  
  6. //OnFilterScriptInit/OnGameModeInit
  7. Race_TD = TextDrawCreate(17.000000, 429.000000, "00:00");
  8. TextDrawBackgroundColor(Race_TD, 65535);
  9. TextDrawFont(Race_TD, 1);
  10. TextDrawLetterSize(Race_TD, 0.500000, 1.000000);
  11. TextDrawColor(Race_TD, 16777215);
  12. TextDrawSetOutline(Race_TD, 1);
  13. TextDrawSetProportional(Race_TD, 1);
  14. Race_TimeCounter = SetTimer("UpdateTime", 200, true);
  15.  
  16.  
  17. //OnPlayerConnect
  18. TextDrawShowForPlayer(playerid, Race_TD);
  19.  
  20.  
  21. //On Bottom of your script.
  22. forward UpdateTime();
  23. public UpdateTime()
  24. {
  25.     if(RaceTimer == 0)
  26.     {
  27.         TextDrawSetString(Race_TD, "00:00");
  28.     }
  29.     else
  30.     {
  31.         new Str[34], x[2];
  32.         new Total = GetTickCount() - RaceTimer;
  33.         x[0] = Total/60000;
  34.         Total -= x[0]*60000;
  35.         x[1] = Total / 1000;
  36.         Total -= x[1]*1000;
  37.         format(Str, sizeof(Str), "%02d:%02d", x[0], x[1]);
  38.         TextDrawSetString(Race_TD, Str);
  39.     }
  40.     return 1;
  41. }
  42.  
  43. //Whereever you want to freeze the timer:
  44. if(Race_TimeCounter != -1) KillTimer(Race_TimeCounter);
  45. Race_TimeCounter = -1;
  46.  
  47. //To start it again (we just prevent bugs, by checking if it runs already):
  48. if(Race_TimeCounter != -1) KillTimer(Race_TimeCounter);
  49. Race_TimeCounter = SetTimer("UpdateTime", 200, true);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement