Advertisement
Guest User

Gappy

a guest
Nov 30th, 2009
347
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.17 KB | None | 0 0
  1. /*
  2.     TDCountDown by Gappy
  3. */
  4.  
  5. #if defined _TDCountDown_included
  6.     #endinput
  7. #endif
  8.  
  9. #include <a_samp>
  10.  
  11. #define _TDCountDown_included
  12. #pragma library TDCountDown
  13.  
  14. /*Natives
  15. native TDCountDown(minutes, seconds, Float:x, Float:y)
  16. native TDCDSetTime(minutes, seconds)
  17. native TDCDShowForPlayer(playerid)
  18. native TDCDHideForPlayer(playerid)
  19. native TDCDShowForAll()
  20. native TDCDHideForAll()
  21. */
  22.  
  23. new Text:CDTD;
  24. new CDsec;
  25. new CDmin;
  26. new Float:TDPx;
  27. new Float:TDPy;
  28. new TDTimer;
  29. forward CDTimer();
  30. forward OnCountDownEnd();
  31.  
  32. stock TDCountDown(minutes, seconds, Float:x, Float:y)
  33. {
  34.     CDmin = minutes;
  35.     CDsec = seconds;
  36.     TDPx = x;
  37.     TDPy = y;
  38.     if(CDmin == 0 && CDsec == 0)
  39.     {
  40.         return 1;
  41.     }
  42.     CDTD = TextDrawCreate(TDPx,TDPy, "CDTD");
  43.     TextDrawTextSize(CDTD,636.000000,824.000000);
  44.     TextDrawAlignment(CDTD, 2);
  45.     TextDrawFont(CDTD,3);
  46.     TextDrawLetterSize(CDTD,0.499999,1.800000);
  47.     TextDrawColor(CDTD,0xffffffff);
  48.     TextDrawSetProportional(CDTD,2);
  49.     TextDrawSetShadow(CDTD,1);
  50.     TextDrawSetOutline(CDTD, 1);
  51.     TDTimer = SetTimer("CDTimer",1000,1);
  52.     return 1;
  53. }
  54.  
  55. public CDTimer()
  56. {
  57.     new string[128];
  58.    
  59.     if(CDsec >= 1)
  60.     {
  61.         format(string,sizeof(string), "~w~%02d:%02d",CDmin, CDsec);
  62.         TextDrawSetString(CDTD, string);
  63.         CDsec--;
  64.     }
  65.     else if(CDsec == 0 && CDmin != 0)
  66.     {
  67.         format(string,sizeof(string), "~w~%02d:%02d",CDmin, CDsec);
  68.         TextDrawSetString(CDTD, string);
  69.         CDsec = 59;
  70.         CDmin--;
  71.     }
  72.     else if(CDmin == 0 && CDsec == 0)
  73.     {
  74.         TextDrawSetString(CDTD, "00:00");
  75.         KillTimer(TDTimer);
  76.         OnCountDownEnd();
  77.     }
  78.     return 1;
  79. }
  80.  
  81. stock TDCDSetTime(minutes, seconds)
  82. {
  83.     new string[128];
  84.     CDmin = minutes;
  85.     CDsec = seconds;
  86.     format(string,sizeof(string), "~w~%02d:%02d",CDmin, CDsec);
  87.     TextDrawSetString(CDTD, string);
  88.     KillTimer(TDTimer);
  89.     TDTimer = SetTimer("CDTimer",1000,1);
  90.     return 1;
  91. }
  92.  
  93. stock TDCDShowForPlayer(playerid)
  94. {
  95.     TextDrawShowForPlayer(playerid, CDTD);
  96.     return 1;
  97. }
  98. stock TDCDHideForPlayer(playerid)
  99. {
  100.     TextDrawHideForPlayer(playerid, CDTD);
  101.     return 1;
  102. }
  103.  
  104. stock TDCDHideForAll()
  105. {
  106.     TextDrawHideForAll(CDTD);
  107.     return 1;
  108. }
  109.  
  110. stock TDCDShowForAll()
  111. {
  112.     TextDrawShowForAll(CDTD);
  113.     return 1;
  114. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement