Advertisement
Guest User

Cronômetro

a guest
Nov 27th, 2016
147
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.22 KB | None | 0 0
  1. #define FILTERSCRIPT
  2. #include <a_samp>
  3. new gRaceStart;
  4.  
  5. public OnFilterScriptInit()
  6. {
  7. createTextDraws();
  8. SetTimer("updateTime",1000,true);
  9. return 1;
  10. }
  11.  
  12. public OnFilterScriptExit()
  13. {
  14. return 1;
  15. }
  16.  
  17. new Text:Ttime;
  18. new gMinutes, gSeconds;
  19. new gindex;
  20.  
  21. forward updateTime(playerid);
  22.  
  23.  
  24. public updateTime()
  25. {
  26. new Time, timestamp;
  27. timestamp = GetTickCount();
  28. if (gRaceStart != 0)
  29. Time = timestamp - gRaceStart;
  30. else
  31. Time=0;
  32.  
  33. new MSeconds;
  34. timeconvert(Time, gMinutes, gSeconds, MSeconds);
  35. gindex=0;
  36. while (gSeconds > 9)
  37. {
  38. gSeconds-=10;
  39. gindex++;
  40. }
  41. new tmp[10];
  42. format(tmp,10,"%d:%d%d",gMinutes,gindex,gSeconds);
  43. TextDrawSetString(Ttime, tmp);
  44. }
  45.  
  46. createTextDraws()
  47. {
  48. Ttime = TextDrawCreate(563.0, 376.0, "00:00");
  49. TextDrawLetterSize(Ttime, 0.6, 3);
  50. }
  51.  
  52. public OnPlayerConnect(playerid)
  53. {
  54. gRaceStart=GetTickCount();
  55. TextDrawShowForPlayer(playerid, Ttime);
  56. return 1;
  57. }
  58.  
  59.  
  60. timeconvert(Time, &Minutes, &Seconds, &MSeconds)
  61. {
  62. new Float:fTime = floatdiv(Time, 60000);
  63. Minutes = floatround(fTime, floatround_tozero);
  64. Seconds = floatround(floatmul(fTime - Minutes, 60), floatround_tozero);
  65. MSeconds = floatround(floatmul(floatmul(fTime - Minutes, 60) - Seconds, 1000), floatround_tozero);
  66. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement