Advertisement
Hyuna

[JailBreak] Countdown Menu v1.0 by Hyuna

Jun 8th, 2016
824
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 5.62 KB | None | 0 0
  1. /*
  2.       AMX Mod X Plugin: Countdown menu for JailBreak
  3.     Copyright (C) 2016  Hyuna aka NorToN
  4.  
  5.     This program is free software: you can redistribute it and/or modify
  6.     it under the terms of the GNU General Public License as published by
  7.     the Free Software Foundation, either version 3 of the License, or
  8.     (at your option) any later version.
  9.  
  10.     This program is distributed in the hope that it will be useful,
  11.     but WITHOUT ANY WARRANTY; without even the implied warranty of
  12.     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  13.     GNU General Public License for more details.
  14.  
  15.     You should have received a copy of the GNU General Public License
  16.     along with this program.  If not, see <http://www.gnu.org/licenses/>.
  17. */
  18.  
  19. #include <amxmodx>
  20. #include <cstrike>
  21. #include <fakemeta>
  22.  
  23. #if AMXX_VERSION_NUM < 183
  24.     #assert Amx Mod X Version 1.83 and above is needed to run this plugin!
  25. #endif
  26.  
  27. #define semicolon 1
  28.  
  29. #define MAX_TEAMS 4
  30. #define MAX_SOUNDS 3
  31.  
  32. #define PREFIX "^3[ ^4JailBreak ^1]"
  33.  
  34. #define MAX_SEC 60
  35. #define MIN_SEC 5
  36. #define SEC_STEP 5
  37.  
  38. #define ADMIN_ACCESS ADMIN_BAN
  39.  
  40. #define TASKID_CD 1337
  41.  
  42. new const g_sTeamNames[MAX_TEAMS] [] = {
  43.     "None",
  44.   "Terrorist",
  45.   "Counter Terrorist",
  46.   "All"
  47. };
  48.  
  49. new const g_sSoundNames[MAX_SOUNDS] [] = {
  50.   "No Sound",
  51.   "Male Voice",
  52.   "Female Voice"
  53. }
  54.  
  55. new g_iFreeze, g_iSound, g_iCounter = MIN_SEC;
  56. new bool:g_bStatus;
  57.  
  58. public plugin_init() {
  59.   register_plugin("[JB] Countdown","v1.0","Hyuna");
  60.  
  61.   register_saycmd("cd","ActionCountDown");
  62.   register_saycmd("countdown","ActionCountDown");
  63. }
  64.  
  65. public ActionCountDown(client) {
  66.   static some[256], iMenu, iCallback;
  67.  
  68.     if ((get_user_flags(client) & ADMIN_ACCESS) || (cs_get_user_team(client) == CS_TEAM_CT && is_user_alive(client)))
  69.     {
  70.       iMenu = menu_create("[JailBreak] CountDown Menu","mHandler");
  71.       iCallback = menu_makecallback("mCallback");
  72.  
  73.         formatex(some,charsmax(some),"Time: \d[ \r%d Seconds \d]",g_iCounter);
  74.         menu_additem(iMenu,some,.callback=iCallback);
  75.  
  76.         formatex(some,charsmax(some),"Sound: \d[ \r%s \d]",g_sSoundNames[g_iSound]);
  77.         menu_additem(iMenu,some,.callback=iCallback);
  78.  
  79.         formatex(some,charsmax(some),"Freeze Team: \d[ \r%s \d]",g_sTeamNames[g_iFreeze]);
  80.         menu_additem(iMenu,some,.callback=iCallback);
  81.  
  82.         menu_additem(iMenu,(g_bStatus ? "Stop Countdown":"Start Countdown"));
  83.  
  84.         menu_display(client,iMenu);
  85. }
  86.  
  87. else
  88. {
  89.     client_print_color(0,print_team_red,"%s ^3Access denied^1! You must be an ^4Alive Guard^1 or an ^4Admin^1.",PREFIX);
  90.     client_cmd(client,"spk ^"\vox/access denied^"");
  91. }
  92.  
  93.     return PLUGIN_HANDLED;
  94. }
  95.  
  96. public mCallback(client, menu, item) {
  97.     return (g_bStatus ? ITEM_DISABLED:ITEM_ENABLED);
  98. }
  99.  
  100. public mHandler(client, menu, item) {
  101.     static szName[32], players[32], pnum, i;
  102.  
  103.     switch(item)
  104.     {
  105.         case 0:
  106.         {
  107.             g_iCounter+=SEC_STEP;
  108.  
  109.             if (g_iCounter > MAX_SEC )
  110.                 g_iCounter = MIN_SEC;
  111.         }
  112.  
  113.         case 1:
  114.         {
  115.             if (++g_iSound == MAX_SOUNDS)
  116.                 g_iSound = 0;
  117.         }
  118.  
  119.         case 2:
  120.         {
  121.             if (++g_iFreeze == MAX_TEAMS)
  122.                 g_iFreeze = 0;
  123.         }
  124.  
  125.         case 3:
  126.         {
  127.             g_bStatus = !g_bStatus;
  128.  
  129.             switch(g_bStatus)
  130.             {
  131.                 case false:
  132.                 {
  133.                     get_players(players,pnum,"ah");
  134.  
  135.                     for (i = 0; i < pnum; i++)
  136.                         set_user_freeze(players[i],false);
  137.  
  138.                     g_iCounter = MIN_SEC;
  139.  
  140.                     remove_task(TASKID_CD);
  141.                 }
  142.  
  143.                 case true:
  144.                 {
  145.                     if (g_iFreeze)
  146.                     {
  147.                         if (g_iFreeze < 3)
  148.                             get_players(players,pnum,"aeh",(g_iFreeze == 1 ? "TERRORIST":"CT"));
  149.  
  150.                         else
  151.                             get_players(players,pnum,"ah");
  152.  
  153.                         for (i = 0; i < pnum; i++)
  154.                             set_user_freeze(players[i],true);
  155.                     }
  156.  
  157.                     set_task(1.0,"taskCountDown",TASKID_CD,.flags="b");
  158.                 }
  159.             }
  160.  
  161.             get_user_name(client,szName,charsmax(szName));
  162.             client_print_color(0,client,"%s Admin ^3%s^1 has ^4%sabled^1 Countdown!",PREFIX,szName,(g_bStatus ? "en":"dis"));
  163.         }
  164.     }
  165.  
  166.     menu_destroy(menu);
  167.  
  168.     if (item != MENU_EXIT && item != 3)
  169.         return ActionCountDown(client);
  170.  
  171.     return PLUGIN_HANDLED;
  172. }
  173.  
  174. public taskCountDown(taskid) {
  175.     static szWord[32];
  176.  
  177.     if (g_iCounter < 1)
  178.     {
  179.         client_cmd(0,"spk ^"radio/com_go^"");
  180.  
  181.         set_dhudmessage(0,255,0,-1.0,0.23,0,6.0,6.0);
  182.         show_dhudmessage(0,"Go Go Go!!!");
  183.         client_print_color(0,print_team_default,"%s ^3CountDown^1 is over! ^4Go Go Go^1!!!",PREFIX);
  184.  
  185.         remove_task(taskid);
  186.         g_iCounter = MIN_SEC;
  187.  
  188.         g_bStatus = false;
  189.  
  190.         if (g_iFreeze)
  191.         {
  192.             new players[32], pnum, i;
  193.             get_players(players,pnum,"ah");
  194.  
  195.             for (i = 0; i < pnum; i++)
  196.                 set_user_freeze(players[i],false);
  197.         }
  198.         return;
  199.     }
  200.  
  201.     if (g_iSound)
  202.     {
  203.         num_to_word(g_iCounter,szWord,31);
  204.  
  205.         if (g_iCounter < 21)
  206.         {
  207.             if (g_iSound == 2)
  208.                 client_cmd(0,"spk ^"\fvox/%s^"",szWord);
  209.  
  210.             else
  211.                 client_cmd(0,"spk ^"\vox/%s second%s^"",szWord,g_iCounter > 1 ? "s":"");
  212.         }
  213.  
  214.         else
  215.             client_cmd(0,"spk ^"\%svox/%s^"",(g_iSound == 2 ? "f":""),szWord);
  216.     }
  217.  
  218.     set_dhudmessage(random(256),random(256),random(256),-1.0,0.23,0,6.0,0.5);
  219.     show_dhudmessage(0,"CountDown: %d Second%s Left",g_iCounter,g_iCounter > 1 ? "s":"");
  220.  
  221.     g_iCounter--;
  222. }
  223.  
  224. stock set_user_freeze(client, bool:bFreeze) {
  225.     set_pev(client,pev_flags,(bFreeze ? (pev(client,pev_flags) | FL_FROZEN): (pev(client,pev_flags) & ~FL_FROZEN)));
  226. }
  227.  
  228. stock register_saycmd(const cmd[], const function[]) {
  229.     static const cmdsay[][] = { "say", "say_team" };
  230.     static const marks[] = { '!', '/', '.' };
  231.     static some[64], i, j;
  232.  
  233.     for (i = 0; i < 2; i++)
  234.     {
  235.         for (j = 0; j < 3; j++)
  236.         {
  237.             formatex(some,charsmax(some),"%s %c%s",cmdsay[i],marks[j],cmd);
  238.             register_clcmd(some,function);
  239.         }
  240.     }
  241. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement