muHamad-asYraf-aKmal

[FilterScript] Count_Down System (Original From [Ak]mal)

May 28th, 2015
654
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 4.35 KB | None | 0 0
  1. //==============================================================================
  2. //------------------------------------------------------------------------------
  3. // If You Find Bug In This Script Pm Me ([email protected]) Okay!
  4. // Thank You To Support My Work :D
  5. //------------------------------------------------------------------------------
  6. //==============================================================================
  7. #include <a_samp>
  8. #include <zcmd>
  9. #include <sscanf>
  10.  
  11. new CountDown, Cd_Timer;
  12.  
  13. public OnFilterScriptInit()
  14. {
  15.     // Just Don't Edit If You Found Bug!
  16.     CountDown = 0;
  17.     return 1;
  18. }
  19.  
  20. public OnFilterScriptExit()
  21. {
  22.     CountDown = 0;
  23.     return 1;
  24. }
  25.  
  26. cmd(cd, playerid, params[]) { return cmd_countdown(playerid, params); }
  27. cmd(countdown, playerid, params[])
  28. {
  29.     new sec, fz, string[MAX_PLAYERS];
  30.     if(sscanf(params, "dd", sec, fz)) return SendClientMessage(playerid, 0xFF0000FF, "Usage: /countdown [seconds] [freeze (0/1)]");
  31.     if(CountDown == 1) return SendClientMessage(playerid, 0xFF0000FF, "Error: Countdown already in progress!");
  32.     if(sec < 1 || sec > 10) return SendClientMessage(playerid, 0xFF0000FF, "Error: Seconds between 1 - 10");
  33.     if(fz < 0 || fz > 1) return SendClientMessage(playerid, 0xFF0000FF, "Error: Use only 0 (With freeze) and 1 (Without freeze)!");
  34.     if(fz == 1)
  35.     {
  36.         for(new i = 0; i < MAX_PLAYERS; i++)
  37.         {
  38.             if(IsPlayerConnected(i))
  39.             TogglePlayerControllable(i, 0);
  40.         }
  41.     }
  42.  
  43.     if(sec == 10) { Cd_Timer = SetTimer("CountDown10", 1000, false); }
  44.     if(sec == 9) { Cd_Timer = SetTimer("CountDown9", 1000, false); }
  45.     if(sec == 8) { Cd_Timer = SetTimer("CountDown8", 1000, false); }
  46.     if(sec == 7) { Cd_Timer = SetTimer("CountDown7", 1000, false); }
  47.     if(sec == 6) { Cd_Timer = SetTimer("CountDown6", 1000, false); }
  48.     if(sec == 5) { Cd_Timer = SetTimer("CountDown5", 1000, false); }
  49.     if(sec == 4) { Cd_Timer = SetTimer("CountDown4", 1000, false); }
  50.     if(sec == 3) { Cd_Timer = SetTimer("CountDown3", 1000, false); }
  51.     if(sec == 2) { Cd_Timer = SetTimer("CountDown2", 1000, false); }
  52.     if(sec == 1) { Cd_Timer = SetTimer("CountDown1", 1000, false); }
  53.     format(string, sizeof(string), ":: %s (%d) has started countdown from %d seconds, (Freeze: %d) ::", IsPlayerName(playerid), playerid, sec, fz);
  54.     SendClientMessageToAll(0x99FF00FF, string);
  55.     CountDown = 1;
  56.     return 1;
  57. }
  58.  
  59. forward CountDown10();
  60. forward CountDown9();
  61. forward CountDown8();
  62. forward CountDown7();
  63. forward CountDown6();
  64. forward CountDown5();
  65. forward CountDown4();
  66. forward CountDown3();
  67. forward CountDown2();
  68. forward CountDown1();
  69. forward CountDown0();
  70.  
  71. public CountDown10()
  72. {
  73.     //
  74.     GameTextForAll("~p~:: 10 ::", 999, 3);
  75.     KillTimer(Cd_Timer);
  76.     Cd_Timer = SetTimer("CountDown9", 1000, false);
  77. }
  78. public CountDown9()
  79. {
  80.     //
  81.     GameTextForAll("~b~:: 9 ::", 999, 3);
  82.     KillTimer(Cd_Timer);
  83.     Cd_Timer = SetTimer("CountDown8", 1000, false);
  84. }
  85. public CountDown8()
  86. {
  87.     //
  88.     GameTextForAll("~p~:: 8 ::", 999, 3);
  89.     KillTimer(Cd_Timer);
  90.     Cd_Timer = SetTimer("CountDown7", 1000, false);
  91. }
  92. public CountDown7()
  93. {
  94.     //
  95.     GameTextForAll("~b~:: 7 ::", 999, 3);
  96.     KillTimer(Cd_Timer);
  97.     Cd_Timer = SetTimer("CountDown6", 1000, false);
  98. }
  99. public CountDown6()
  100. {
  101.     //
  102.     GameTextForAll("~p~:: 6 ::", 999, 3);
  103.     KillTimer(Cd_Timer);
  104.     Cd_Timer = SetTimer("CountDown5", 1000, false);
  105. }
  106. public CountDown5()
  107. {
  108.     //
  109.     GameTextForAll("~b~:: 5 ::", 999, 3);
  110.     KillTimer(Cd_Timer);
  111.     Cd_Timer = SetTimer("CountDown4", 1000, false);
  112. }
  113. public CountDown4()
  114. {
  115.     //
  116.     GameTextForAll("~p~:: 4 ::", 999, 3);
  117.     KillTimer(Cd_Timer);
  118.     Cd_Timer = SetTimer("CountDown3", 1000, false);
  119. }
  120. public CountDown3()
  121. {
  122.     //
  123.     GameTextForAll("~b~:: 3 ::", 999, 3);
  124.     KillTimer(Cd_Timer);
  125.     Cd_Timer = SetTimer("CountDown2", 1000, false);
  126. }
  127. public CountDown2()
  128. {
  129.     //
  130.     GameTextForAll("~p~:: 2 ::", 999, 3);
  131.     KillTimer(Cd_Timer);
  132.     Cd_Timer = SetTimer("CountDown1", 1000, false);
  133. }
  134. public CountDown1()
  135. {
  136.     //
  137.     GameTextForAll("~b~:: 1 ::", 999, 3);
  138.     KillTimer(Cd_Timer);
  139.     Cd_Timer = SetTimer("CountDown0", 1000, false);
  140. }
  141. public CountDown0()
  142. {
  143.     //
  144.     GameTextForAll("~r~:: GO! GO! GO! ::", 999, 3);
  145.     CountDown = 0;
  146.     for(new i = 0; i < MAX_PLAYERS; i++)
  147.     {
  148.         if(IsPlayerConnected(i))
  149.         TogglePlayerControllable(i, 0);
  150.     }
  151.     KillTimer(Cd_Timer);
  152. }
  153.  
  154. stock IsPlayerName(playerid)
  155. {
  156.     new name[MAX_PLAYER_NAME];
  157.     GetPlayerName(playerid, name, sizeof(name));
  158.     return name;
  159. }
Advertisement
Add Comment
Please, Sign In to add comment