raizo21

Ban Menu

Feb 18th, 2021
1,340
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /* Plugin generated by AMXX-Studio */
  2.  
  3. #include <amxmodx>
  4. #include <amxmisc>
  5.  
  6. #define PLUGIN "Reasons Ban Menu"
  7. #define VERSION "1.0"
  8. #define AUTHOR "raizo"
  9.  
  10. #pragma tabsize 0
  11. #pragma compress 1
  12.  
  13. #define MAX_REASONS 32
  14.  
  15. enum reasons
  16. {
  17.     Reason1 = 1,
  18.     Reason2,
  19.     Reason3,
  20.     Reason4,
  21.     Reason5
  22. }
  23.  
  24. enum thetime
  25. {
  26.     maxtime1 = 1,
  27.     maxtime2,
  28.     maxtime3,
  29.     maxtime4,
  30.     maxtime5
  31. }
  32.  
  33. enum reasons_config
  34. {
  35.     reasons:reason_menu,
  36.     thetime:time_menu
  37. }
  38.  
  39. new all_reasons[MAX_REASONS+1][reasons_config]
  40.  
  41. new szResult[64], szTime[64]
  42. new szTmp[192]
  43. new szArg[ 21 ];
  44.  
  45. new his_reason[33]
  46.  
  47. public plugin_init()
  48. {
  49.     register_plugin(PLUGIN, VERSION, AUTHOR)
  50.  
  51.     register_clcmd("say /banmenu", "ban_menu_reasons");
  52.  
  53.     register_clcmd("Type_your_reason","set_reason");
  54. }
  55.  
  56.  
  57. public set_reason( id )
  58. {
  59.     read_argv(1, szArg, sizeof ( szArg ) -1 );
  60.  
  61.     if ( !strlen( szArg ) || strlen( szArg ) < 5 )
  62.     {
  63.         client_cmd( id, "messagemode Type_your_reason" );
  64.         return PLUGIN_HANDLED;
  65.     }
  66.     else if( strlen( szArg ) > 50 )
  67.     {
  68.         client_cmd( id, "messagemode Type_your_reason" );
  69.         return PLUGIN_HANDLED;
  70.     }
  71.     Search_Player(id)
  72.  
  73.     return PLUGIN_HANDLED;
  74. }
  75.  
  76.  
  77.  
  78. public ban_menu_reasons(id)
  79. {
  80.     new flags = get_user_flags(id)
  81.     if(!(flags & ADMIN_BAN))
  82.     {
  83.         client_print(id,print_chat,"You have no access to this command")
  84.         return PLUGIN_HANDLED
  85.     }
  86.  
  87.     new menu = menu_create("\y[\r Ban Menu \y ]\w By raizo","menu_handled")
  88.  
  89.     formatex(szTmp,charsmax(szTmp),"Choose Reason \r%s",reason_results(all_reasons[id][reason_menu]));
  90.     menu_additem(menu,szTmp,"1")
  91.  
  92.     formatex(szTmp,charsmax(szTmp),"Type Reason");
  93.     menu_additem(menu,szTmp,"2")
  94.  
  95.     formatex(szTmp,charsmax(szTmp),"Choose Time \r%s",times_results(all_reasons[id][time_menu]));
  96.     menu_additem(menu,szTmp,"3")
  97.  
  98.     formatex(szTmp,charsmax(szTmp),"Choose Player");
  99.     menu_additem(menu,szTmp,"4")
  100.  
  101.  
  102.     menu_display(id,menu)
  103.  
  104.     return PLUGIN_HANDLED;
  105. }
  106.  
  107. public menu_handled(id,menu,item)
  108. {
  109.     if(item == MENU_EXIT)
  110.     {
  111.         menu_destroy(menu);
  112.  
  113.         return PLUGIN_HANDLED;
  114.     }
  115.  
  116.     new data[3], iName[64]
  117.     new access, callback;
  118.     menu_item_getinfo(menu, item, access, data,2, iName, 63, callback);
  119.     new key = str_to_num(data)
  120.  
  121.     switch(key)
  122.     {
  123.     case 1:
  124.     {
  125.         all_reasons[id][reason_menu] = ( ++all_reasons[id][reason_menu] > (reasons:5) ) ? (reasons:1) :all_reasons[id][reason_menu]
  126.         his_reason[id] = 1
  127.     }
  128.     case 2:
  129.     {
  130.         set_reason(id)
  131.         his_reason[id] = 2
  132.         return PLUGIN_HANDLED;
  133.     }
  134.     case 3:
  135.     {
  136.         all_reasons[id][time_menu] = ( ++all_reasons[id][time_menu] > (thetime:5) ) ? (thetime:1) :all_reasons[id][time_menu]
  137.     }
  138.     case 4:
  139.     {
  140.         Search_Player(id)
  141.         return PLUGIN_HANDLED;
  142.     }
  143.     }
  144.         menu_destroy(menu);
  145.  
  146.         ban_menu_reasons(id)
  147.  
  148.         return PLUGIN_HANDLED;
  149. }
  150.  
  151. public Search_Player( id )
  152. {
  153.     new menu = menu_create( "\rChoose Your Player!:", "menu_player_handler" );
  154.  
  155.     new players[32], pnum, tempid;
  156.  
  157.     new szName[32], szUserId[32];
  158.  
  159.     get_players( players, pnum, "a" );
  160.  
  161.     for ( new i; i<pnum; i++ )
  162.     {
  163.         tempid = players[i];
  164.  
  165.         get_user_name( tempid, szName, charsmax( szName ) );
  166.  
  167.         formatex( szUserId, charsmax( szUserId ), "%d", get_user_userid( tempid ) );
  168.  
  169.         menu_additem( menu, szName, szUserId, 0 );
  170.     }
  171.  
  172.     menu_display( id, menu, 0 );
  173. }
  174.  
  175.  
  176.  
  177. public menu_player_handler( id, menu, item )
  178. {
  179.  
  180.     if ( item == MENU_EXIT )
  181.     {
  182.     menu_destroy( menu );
  183.     return PLUGIN_HANDLED;
  184.     }
  185.  
  186.  
  187.     new szData[6], szName[64];
  188.     new _access, item_callback;
  189.  
  190.     menu_item_getinfo( menu, item, _access, szData,charsmax( szData ), szName,charsmax( szName ), item_callback );
  191.  
  192.     new userid = str_to_num( szData );
  193.  
  194.     new player = find_player( "k", userid );
  195.  
  196.     new idname[33], playername[33]
  197.  
  198.     get_user_name(id,idname,charsmax(idname))
  199.     get_user_name(player,playername,charsmax(playername))
  200.  
  201.     if ( player && is_user_connected( player ) )
  202.     {
  203.         new uIP[32]
  204.         get_user_name(player, uIP, 31)
  205.  
  206.         if (his_reason[id] == 1)
  207.         {
  208.             server_cmd("amx_banip %s %s ^"%s^"", uIP,szTime,szResult)
  209.         }
  210.         else if (his_reason[id] == 2)
  211.         {
  212.             server_cmd("amx_banip %s %s ^"%s^"", uIP,szTime,szArg)
  213.         }
  214.     }
  215.     menu_destroy( menu );
  216.     return PLUGIN_HANDLED;
  217. }
  218.  
  219.  
  220. reason_results(reasons:part)
  221. {
  222.     switch(part)
  223.     {
  224.         case Reason1:    copy(szResult, charsmax(szResult), "Hacker Detected");
  225.         case Reason2:    copy(szResult, charsmax(szResult), "To more ping");
  226.         case Reason3:    copy(szResult, charsmax(szResult), "You speak only boolshit");
  227.         case Reason4:    copy(szResult, charsmax(szResult), "You can change reasons from here");
  228.         case Reason5:    copy(szResult, charsmax(szResult), "Bye Bye");
  229.            
  230.         default:             copy(szResult, charsmax(szResult), "");
  231.      }
  232.     return szResult;
  233. }
  234.  
  235. times_results(thetime:part)
  236. {
  237.     switch(part)
  238.     {
  239.         case maxtime1:    copy(szTime, charsmax(szTime), "15");
  240.         case maxtime2:    copy(szTime, charsmax(szTime), "30");
  241.         case maxtime3:    copy(szTime, charsmax(szTime), "60");
  242.         case maxtime4:    copy(szTime, charsmax(szTime), "120");
  243.         case maxtime5:    copy(szTime, charsmax(szTime), "36000");
  244.            
  245.         default:             copy(szTime, charsmax(szTime), "");
  246.     }
  247.     return szTime;
  248. }
RAW Paste Data