Advertisement
Guest User

Littl3j0hNy

a guest
Jun 23rd, 2013
341
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 4.94 KB | None | 0 0
  1. /*   TextDrawCountDown by Littlejohny (TextDrawCountDown)   */
  2. /*                      by Littlejohny                      */
  3. /*          **************************************          */
  4. /*  TextDrawCountDownForPlayer(playerid, seconds)           */
  5. /*  TextDrawCountDownForAll(seconds)                        */
  6. /*  HideCountDownForPlayer(playerid)                        */
  7. /*  HideCountDownForAll()                                   */
  8.  
  9. #if defined _TextDrawCountDown_included
  10.   #endinput
  11. #endif
  12.  
  13. #include <a_samp>
  14.  
  15. #define _TextDrawCountDown_included
  16. #pragma library TextDrawCountDown
  17.  
  18. #define RED 0xE60000FF
  19.  
  20. new tdcstr[64];
  21.  
  22. new PlayerText:tdcd[MAX_PLAYERS],
  23.     pcdtime[MAX_PLAYERS],
  24.     ptdctimer[MAX_PLAYERS],
  25.     pCOUNT_ON[MAX_PLAYERS] = 0;
  26.  
  27. new cdtime,
  28.     tdctimer,
  29.     COUNT_ON;
  30.  
  31. forward TextDrawCountDownForAll(seconds);
  32. forward TextDrawCountDownForPlayer(playerid, seconds);
  33. forward HideCountDownForAll();
  34. forward HideCountDownForPlayer(playerid);
  35. forward PlayerCountTimer(playerid);
  36. forward TextCountTimer();
  37.  
  38. public OnPlayerConnect(playerid)
  39. {
  40.     tdcd[playerid] = CreatePlayerTextDraw(playerid, 320.000000,410.000000, "TDCD");
  41.     PlayerTextDrawTextSize(playerid, tdcd[playerid],636.000000,824.000000);
  42.     PlayerTextDrawAlignment(playerid, tdcd[playerid], 2);
  43.     PlayerTextDrawFont(playerid, tdcd[playerid],3);
  44.     PlayerTextDrawLetterSize(playerid, tdcd[playerid],0.499999,1.800000);
  45.     PlayerTextDrawColor(playerid, tdcd[playerid],0xffffffff);
  46.     PlayerTextDrawSetProportional(playerid, tdcd[playerid],2);
  47.     PlayerTextDrawSetShadow(playerid, tdcd[playerid],1);
  48.     PlayerTextDrawSetOutline(playerid, tdcd[playerid], 1);
  49.     if(funcidx("tdcd_OnPlayerConnect") != -1) return CallLocalFunction("tdcd_OnPlayerConnect", "d",playerid);
  50.     return 1;
  51. }
  52. #if defined _ALS_OnPlayerConnect
  53.     #undef OnPlayerConnect
  54. #else
  55.     #define _ALS_OnPlayerConnect
  56. #endif
  57. #define OnPlayerConnect tdcd_OnPlayerConnect
  58. forward tdcd_OnPlayerConnect(playerid);
  59.  
  60. public TextDrawCountDownForPlayer(playerid, seconds)
  61. {
  62.     if(pCOUNT_ON[playerid] == 1) return 1;
  63.  
  64.     pcdtime[playerid] = seconds;
  65.     if(pcdtime[playerid] < 1 || pcdtime[playerid] > 30)
  66.     {
  67.         pcdtime[playerid] = 0;
  68.         return 1;
  69.     }
  70.     ptdctimer[playerid] = SetTimerEx("PlayerCountTimer", 1000, 1, "i", playerid);
  71.     pCOUNT_ON[playerid] = 1;
  72.    
  73.     format(tdcstr,sizeof(tdcstr), "~w~CountDown: ~r~%d ~w~second/s", pcdtime[playerid]);
  74.     pcdtime[playerid]--;
  75.    
  76.     PlayerTextDrawSetString(playerid, tdcd[playerid], tdcstr);
  77.     PlayerTextDrawShow(playerid, tdcd[playerid]);
  78.     PlayerPlaySound(playerid, 1058, 0.0, 0.0, 0.0);
  79.     return 1;
  80. }
  81.  
  82. public TextDrawCountDownForAll(seconds)
  83. {
  84.     if(COUNT_ON == 1) return 1;
  85.  
  86.     COUNT_ON = 1;
  87.     cdtime = seconds;
  88.     if(cdtime < 1 || cdtime > 30)
  89.     {
  90.         cdtime = 0;
  91.         return 1;
  92.     }
  93.     tdctimer = SetTimer("TextCountTimer", 1000, 1);
  94.    
  95.     format(tdcstr,sizeof(tdcstr), "~w~CountDown: ~r~%d ~w~second/s", cdtime);
  96.     cdtime--;
  97.    
  98.     for (new i = 0; i < MAX_PLAYERS; i++)
  99.     {
  100.         if(IsPlayerConnected(i) && pCOUNT_ON[i] == 0)
  101.         {
  102.             PlayerTextDrawSetString(i, tdcd[i], tdcstr);
  103.             PlayerTextDrawShow(i, tdcd[i]);
  104.             PlayerPlaySound(i, 1058, 0.0, 0.0, 0.0);
  105.         }
  106.     }
  107.     return 1;
  108. }
  109.  
  110. public HideCountDownForPlayer(playerid)
  111. {
  112.     PlayerTextDrawHide(playerid, tdcd[playerid]);
  113.     pCOUNT_ON[playerid] = 0;
  114.     return 1;
  115. }
  116.  
  117. public HideCountDownForAll()
  118. {
  119.     for (new i = 0; i < MAX_PLAYERS; i++)
  120.     {
  121.         if(IsPlayerConnected(i) && pCOUNT_ON[i] == 0)
  122.         {
  123.             PlayerTextDrawHide(i, tdcd[i]);
  124.         }
  125.     }
  126.     COUNT_ON = 0;
  127.     return 1;
  128. }
  129.  
  130. public TextCountTimer()
  131. {
  132.     if(cdtime <= 30 && cdtime >= 1)
  133.     {
  134.         format(tdcstr,sizeof(tdcstr), "~w~CountDown: ~r~%d ~w~second/s", cdtime);
  135.         cdtime--;
  136.  
  137.         for (new i = 0; i < MAX_PLAYERS; i++)
  138.         {
  139.             if(IsPlayerConnected(i) && pCOUNT_ON[i] == 0)
  140.             {
  141.                 PlayerTextDrawSetString(i, tdcd[i], tdcstr);
  142.                 PlayerTextDrawShow(i, tdcd[i]);
  143.                 PlayerPlaySound(i, 1058, 0.0, 0.0, 0.0);
  144.             }
  145.         }
  146.     }
  147.     else if(cdtime == 0)
  148.     {
  149.         for (new i = 0; i < MAX_PLAYERS; i++)
  150.         {
  151.             if(IsPlayerConnected(i) && pCOUNT_ON[i] == 0)
  152.             {
  153.                 KillTimer(tdctimer);
  154.                 PlayerTextDrawSetString(i, tdcd[i], "~w~CountDown: ~g~GO !~g~ GO !~g~ GO !");
  155.                 PlayerTextDrawShow(i, tdcd[i]);
  156.                 PlayerPlaySound(i, 1056, 0.0, 0.0, 0.0);
  157.             }
  158.         }
  159.         SetTimer("HideCountDownForAll", 3000, 0);
  160.     }
  161.     return 1;
  162. }
  163.  
  164. public PlayerCountTimer(playerid)
  165. {
  166.     if(pcdtime[playerid] <= 30 && pcdtime[playerid] >= 1)
  167.     {
  168.         format(tdcstr,sizeof(tdcstr), "~w~CountDown: ~r~%d ~w~second/s", pcdtime[playerid]);
  169.         PlayerTextDrawSetString(playerid, tdcd[playerid], tdcstr);
  170.         PlayerTextDrawShow(playerid, tdcd[playerid]);
  171.         PlayerPlaySound(playerid, 1058, 0.0, 0.0, 0.0);
  172.         pcdtime[playerid]--;
  173.     }
  174.     else if(pcdtime[playerid] == 0)
  175.     {
  176.             KillTimer(ptdctimer[playerid]);
  177.             PlayerTextDrawSetString(playerid, tdcd[playerid], "~w~CountDown: ~g~GO !~g~ GO !~g~ GO !");
  178.             PlayerTextDrawShow(playerid, tdcd[playerid]);
  179.             SetTimerEx("HideCountDownForPlayer", 3000, 0, "i", playerid);
  180.             PlayerPlaySound(playerid, 1056, 0.0, 0.0, 0.0);
  181.     }
  182.     return 1;
  183. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement