Advertisement
RanAway

[ Pawn - advanced plugins ] advanced mute menu

May 29th, 2022 (edited)
1,530
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 26.10 KB | None | 0 0
  1. //-------------------- Includes --------------------//
  2. #include < amxmodx >
  3. #include < fakemeta >
  4.  
  5. //-------------------- Defines --------------------//
  6. #define Prefix              "AMXX"
  7. #define ACCESS_ADMIN        ADMIN_IMMUNITY
  8.  
  9. //-------------------- Functions --------------------//
  10. enum { CHAT, VOICE, ASKFOR }
  11. new bool:muteall[ 33 ], bool:mutesystem[ 33 ][ 33 ][ 3 ], bool:sortmenu[ 33 ]
  12. new askforremove[ 33 ], whoaskme[ 33 ], adminremember[ 33 ]
  13.  
  14. //-------------------- Plugin init --------------------//
  15. public plugin_init()
  16. {
  17.     register_plugin( "advanced mute menu", "v1.0", "RanAway`" )
  18.  
  19.     //-------------------- Commands --------------------//
  20.     register_clcmd( "say /mute", "mainmenu" )
  21.  
  22.     register_message( get_user_msgid( "SayText" ), "Chat" )     //------ chat --------//
  23.     register_forward( FM_Voice_SetClientListening, "Voice" )    //------ voice --------//
  24. }
  25.  
  26. //-------------------- chat --------------------//
  27. public Chat( Msgid, Msgdest, id )
  28. {
  29.     new player = get_msg_arg_int( 1 )
  30.  
  31.     if( is_user_connected( player ) && mutesystem[ id ][ player ][ CHAT ] ) return 1
  32.  
  33.     return 0
  34. }
  35.  
  36. //-------------------- voice --------------------//
  37. public Voice( Rec, Send, List )
  38. {
  39.     if( Rec == Send ) return FMRES_IGNORED
  40.  
  41.     if( mutesystem[ Rec ][ Send ][ VOICE ] )
  42.     {
  43.         engfunc( EngFunc_SetClientListening, Rec, Send, 0 )
  44.         return FMRES_SUPERCEDE
  45.     }
  46.  
  47.     return FMRES_IGNORED
  48. }
  49.  
  50. //-------------------- main menu --------------------//
  51. public mainmenu( id )
  52. {
  53.     //-------------------- to prevent heap low --------------------//
  54.     if( !is_user_connected( id ) ) return 1
  55.  
  56.     new item[ 512 ], bool:blocksee = true, menu = menu_create( fmt( "\r[\w %s \r]\w mute menu", Prefix ), "sub_mainmenu" )
  57.  
  58.     //----- Block "see who muted you" if no one is muted you -----//
  59.     for( new i = 1; i <= get_maxplayers(); i++ ) if( mutesystem[ i ][ id ][ VOICE ] || mutesystem[ i ][ id ][ CHAT ] ) blocksee = false
  60.  
  61.     get_playersnum() > 1 ? menu_additem( menu, "voice" ) : menu_addtext2( menu, "\r1. \dvoice" )
  62.     get_playersnum() > 1 ? menu_additem( menu, "chat^n" ) : menu_addtext2( menu, "\r2. \dchat^n" )
  63.  
  64.     formatex( item, charsmax( item ), "%s%smute everyone^n", get_playersnum() > 1 ? "" : "\r3. \d", muteall[ id ] ? "un" : "" )
  65.     get_playersnum() > 1 ? menu_additem( menu, item ) : menu_addtext2( menu, item )
  66.  
  67.     blocksee ? menu_addtext2( menu, "\r4. \dsee who muted you" ) : menu_additem( menu, "see who muted you" )
  68.     get_user_flags( id ) & ACCESS_ADMIN ? menu_additem( menu, "admin options" ) : menu_addtext2( menu, "\r5. \dadmin options" )
  69.  
  70.     menu_display( id, menu )
  71.     return 1
  72. }
  73.  
  74. public sub_mainmenu( id, menu, item )
  75. {
  76.     if( item == MENU_EXIT ) return menu_destroy( menu )
  77.  
  78.     if( item == 0 ) sortmenu[ id ] = true                       // Change the menu to voice
  79.     if( item == 1 ) sortmenu[ id ] = false                      // Change the menu to chat
  80.     if( item == 2 )                                             // Mute everyone
  81.     {
  82.         muteall[ id ] ^= true
  83.         ColorChat( id, "You've ^3%smuted^1 everyone.", muteall[ id ] ? "" : "un" )
  84.  
  85.         for( new i = 1; i <= get_maxplayers(); i++ )
  86.         {
  87.             //-------------------- If the player is not connected or you or bot or hltv --------------------//
  88.             if( !is_user_connected( i ) || is_user_bot( i ) || is_user_hltv( i ) || i == id ) continue
  89.  
  90.             mutesystem[ id ][ i ][ CHAT ] = muteall[ id ]
  91.             mutesystem[ id ][ i ][ VOICE ] = muteall[ id ]
  92.             mutesystem[ i ][ id ][ ASKFOR ] = false
  93.         }
  94.         return mainmenu( id )
  95.     }
  96.     if( item == 3 ) return whomutememenu( id, 0 )   // See who mute you
  97.     if( item == 4 ) return adminmenu( id )          // Admin menu
  98.  
  99.     return mutemenu( id, 0 )                        // Open the mute menu
  100. }
  101.  
  102. //-------------------- mute menu --------------------//
  103. public mutemenu( id, page )
  104. {
  105.     //-------------------- to prevent heap low --------------------//
  106.     if( !is_user_connected( id ) ) return 1
  107.  
  108.     new data[ 6 ], menu = menu_create( fmt( "\r[\w %s \r]\w mute %s", Prefix, sortmenu[ id ] ? "voice" : "chat" ), "sub_mutemenu" )
  109.  
  110.     for( new i = 1; i <= get_maxplayers(); i++ )
  111.     {
  112.         //-------------------- If the player is not connected or you or bot or hltv --------------------//
  113.         if( !is_user_connected( i ) || is_user_bot( i ) || is_user_hltv( i ) || i == id ) continue
  114.  
  115.         num_to_str( i, data, charsmax( data ) )
  116.         menu_additem( menu, fmt( "%n \d%s", i, ( sortmenu[ id ] && mutesystem[ id ][ i ][ VOICE ] ) || ( !sortmenu[ id ] && mutesystem[ id ][ i ][ CHAT ] ) ? "- [\r muted \d]" : "" ), data )
  117.     }
  118.  
  119.     //-------------------- Previous / Next / Exit --------------------//
  120.     menu_setprop( menu, MPROP_BACKNAME, "previous page" )
  121.     menu_setprop( menu, MPROP_NEXTNAME, "next page" )
  122.     menu_setprop( menu, MPROP_EXITNAME, "back" )
  123.  
  124.     menu_display( id, menu, page )
  125.     return 1
  126. }
  127.  
  128. public sub_mutemenu( id, menu, item )
  129. {
  130.     if( item == MENU_EXIT ) return mainmenu( id )
  131.  
  132.     new data[ 6 ], page
  133.     menu_item_getinfo( menu, item, _, data, charsmax( data ) )
  134.     player_menu_info( id, menu, menu, page )
  135.  
  136.     new player = str_to_num( data )
  137.  
  138.     //-------------------- If the player is not connected --------------------//
  139.     if( !is_user_connected( player ) ) return ColorChat( id, "^3%n^1 is no longer connected.", player ), mutemenu( id, page )
  140.  
  141.     if( sortmenu[ id ] )
  142.     {
  143.         mutesystem[ id ][ player ][ VOICE ] = !mutesystem[ id ][ player ][ VOICE ]
  144.         ColorChat( id, mutesystem[ id ][ player ][ VOICE ] ? "you canno't hear ^3%n^1 until you remove his mute." : "you can hear ^3%n^1 now.", player )
  145.     }
  146.     else if( !sortmenu[ id ] )
  147.     {
  148.         mutesystem[ id ][ player ][ CHAT ] = !mutesystem[ id ][ player ][ CHAT ]
  149.         ColorChat( id, mutesystem[ id ][ player ][ CHAT ] ? "you canno't see what ^3%n^1 write until you remove his mute." : "you can see what ^3%n^1 write now.", player )
  150.     }
  151.  
  152.     //---------- If there is even a single player you didnt mute on ( voice / chat ) turn the "Mute everyone" off ------//
  153.     for( new i= 1; i <= get_maxplayers(); i++ ) if( !mutesystem[ id ][ i ][ VOICE ] && !mutesystem[ id ][ i ][ CHAT ] ) muteall[ id ] = false
  154.  
  155.     //---------- If the player that you muted has asked you to remove his mute it will remove his block ----------------//
  156.     mutesystem[ id ][ player ][ ASKFOR ] = false
  157.  
  158.     return mutemenu( id, page )
  159. }
  160.  
  161. //-------------------- See who mute you --------------------//
  162. public whomutememenu( id, page )
  163. {
  164.     //-------------------- to prevent heap low --------------------//
  165.     if( !is_user_connected( id ) ) return 1
  166.  
  167.     new item[ 256 ], data[ 6 ], menu = menu_create( fmt( "\r[\w %s \r]\w see who muted you", Prefix ), "sub_whomenu" )
  168.  
  169.     for( new i = 1, counter = -1; i <= get_maxplayers(); i++ )
  170.     {
  171.         //-------------------- If the player is not connected or yourself or bot or hltv or not muted you --------------------//
  172.         if( !is_user_connected( i ) || i == id || is_user_bot( i ) || is_user_hltv( i ) || ( !mutesystem[ i ][ id ][ VOICE ] && !mutesystem[ i ][ id ][ CHAT ] ) ) continue
  173.  
  174.         num_to_str( i, data, charsmax( data ) )
  175.  
  176.         formatex( item, charsmax( item ), "%n \r[\w %s%s%s \r]%s", i,
  177.         mutesystem[ i ][ id ][ VOICE ] ? "Voice" : "", mutesystem[ i ][ id ][ VOICE ] && mutesystem[ i ][ id ][ CHAT ] ? " \y&\w " : "",
  178.         mutesystem[ i ][ id ][ CHAT ] ? "Chat" : "", mutesystem[ id ][ i ][ ASKFOR ] ? " \d- \wignored your request" : "" )
  179.         mutesystem[ id ][ i ][ ASKFOR ] ? menu_addtext2( menu, fmt( "\r%d. \d%s", ++counter % 6, item ) ) : menu_additem( menu, item, data )
  180.     }
  181.  
  182.     //-------------------- Previous / Next / Exit --------------------//
  183.     menu_setprop( menu, MPROP_BACKNAME, "previous page" )
  184.     menu_setprop( menu, MPROP_NEXTNAME, "next page" )
  185.     menu_setprop( menu, MPROP_EXITNAME, "back" )
  186.  
  187.     menu_display( id, menu, page )
  188.     return 1
  189. }
  190.  
  191. public sub_whomenu( id, menu, item )
  192. {
  193.     if( item == MENU_EXIT ) return mainmenu( id )
  194.  
  195.     new data[ 6 ], page
  196.     menu_item_getinfo( menu, item, _, data, charsmax( data ) )
  197.     player_menu_info( id, menu, menu, page )
  198.  
  199.     //-------------------- If the player is not connected --------------------//
  200.     if( !is_user_connected( str_to_num( data ) ) )
  201.     {
  202.         ColorChat( id, "^3%n^1 is no longer connected.", str_to_num( data ) )
  203.  
  204.         return mainmenu( id )
  205.     }
  206.  
  207.     askforremove[ id ] = str_to_num( data )
  208.  
  209.     mutesystem[ id ][ askforremove[ id ] ][ ASKFOR ] = true     // Block after you asked
  210.     whoaskme[ askforremove[ id ] ] = id                         // Show who ask for remove
  211.  
  212.     acceptionmenu( askforremove[ id ] )                         // Open menu for the player you asked
  213.  
  214.     return whomutememenu( id, page )
  215. }
  216.  
  217. //-------------------- Acception menu --------------------//
  218. public acceptionmenu( id )
  219. {
  220.     //-------------------- to prevent heap low --------------------//
  221.     if( !is_user_connected( id ) ) return 1
  222.  
  223.     new menu = menu_create( fmt( "\r[\w %s \r] \r%n\w ask you to remove his mute", Prefix, whoaskme[ id ] ), "sub_acceptionmenu" )
  224.  
  225.     menu_additem( menu, "accept" )
  226.     menu_additem( menu, "ignore" )
  227.  
  228.     menu_setprop( menu, MPROP_EXIT, MEXIT_NEVER )
  229.     menu_display( id, menu, .time = 10 )
  230.     return 1
  231. }
  232.  
  233. public sub_acceptionmenu( id, menu, item )
  234. {
  235.     if( item == MENU_EXIT ) menu_destroy( menu )
  236.  
  237.     //-------------------- Accept the request --------------------//
  238.     if( item == 0 )
  239.     {
  240.         mutesystem[ id ][ whoaskme[ id ] ][ VOICE ] = false
  241.         mutesystem[ id ][ whoaskme[ id ] ][ CHAT ] = false
  242.         mutesystem[ id ][ whoaskme[ id ] ][ ASKFOR ] = false
  243.         muteall[ id ] = false
  244.  
  245.         ColorChat( whoaskme[ id ], "^3%n^1 has accept your request and remove your mute.", askforremove[ id ] )
  246.         return ColorChat( id, "You accept ^3%n^1 request and remove his mute.", whoaskme[ id ] )
  247.     }
  248.  
  249.     //-------------------- Ignore the request --------------------//
  250.     ColorChat( whoaskme[ id ], "^3%n^1 has ignored your request to remove your mute.", askforremove[ id ] )
  251.     return ColorChat( id, "You ignored ^3%n^1 request to remove his mute.", whoaskme[ id ] )
  252. }
  253.  
  254. //-------------------- Admin menu --------------------//
  255. public adminmenu( id )
  256. {
  257.     //-------------------- Access to the menu & to prevent heap low --------------------//
  258.     if( ~get_user_flags( id ) & ACCESS_ADMIN || !is_user_connected( id ) ) return 0
  259.  
  260.     new bool:blockwhosee = true, bool:blocksee = true, menu = menu_create( fmt( "\r[\w %s \r]\w admin menu", Prefix ), "sub_adminmenu" )
  261.  
  262.     //-------------------- Block "Show everyone's mute" if no one is muted --------------------//
  263.     for( new i = 1; i <= get_maxplayers(); i++ ) for( new j = 1; j <= get_maxplayers(); j++ )
  264.         if( mutesystem[ i ][ j ][ VOICE ] || mutesystem[ i ][ j ][ CHAT ] ) blockwhosee = false
  265.  
  266.     //----- Block "remove everyone's mute on you" if no one is muted you -----//
  267.     for( new i = 1; i <= get_maxplayers(); i++ ) if( mutesystem[ i ][ id ][ VOICE ] || mutesystem[ i ][ id ][ CHAT ] ) blocksee = false
  268.  
  269.     blockwhosee ? menu_addtext2( menu, "\r1. \dremove \reveryone's\d mutes" ) : menu_additem( menu, "remove \reveryone's\w mutes" )
  270.     blocksee ? menu_addtext2( menu, "\r2. \dremove \reveryone's\d mute on you^n" ) : menu_additem( menu, "remove \reveryone's\w mute on you^n" )
  271.     blockwhosee ? menu_addtext2( menu, "\r3. \dshow everyone's mutes in menu" ) : menu_additem( menu, "show everyone's mutes in menu" )
  272.     get_playersnum() > 1 ? menu_additem( menu, "mute someone for someone else" ) : menu_addtext2( menu, "\r4. \dmute someone for someone else" )
  273.  
  274.     menu_setprop( menu, MPROP_EXITNAME, "back" )
  275.     menu_display( id, menu )
  276.     return 1
  277. }
  278.  
  279. public sub_adminmenu( id, menu, item )
  280. {
  281.     if( item == MENU_EXIT ) return mainmenu( id )
  282.  
  283.     //-------------------- Remove everyone's mutes --------------------//
  284.     if( item == 0 )
  285.     {
  286.         ColorChat( 0, "Everyone's ^3mutes^1 has been ^3removed^1." )
  287.  
  288.         for( new i = 1; i <= get_maxplayers(); i++ )
  289.         {
  290.             //-------------------- If the player is not connected or bot or hltv --------------------//
  291.             if( !is_user_connected( i ) || is_user_bot( i ) || is_user_hltv( i ) ) continue
  292.  
  293.             for( new j = 1; j <= get_maxplayers(); j++ )
  294.             {
  295.                 //-------------------- If the player is not connected or bot or hltv --------------------//
  296.                 if( !is_user_connected( j ) || is_user_bot( j ) || is_user_hltv( j ) ) continue
  297.  
  298.                 mutesystem[ i ][ j ][ VOICE ] = false
  299.                 mutesystem[ i ][ j ][ CHAT ] = false
  300.                 mutesystem[ i ][ j ][ ASKFOR ] = false
  301.                 muteall[ i ] = false
  302.             }
  303.         }
  304.     }
  305.     //-------------------- Remove everyone's mutes on you --------------------//
  306.     if( item == 1 )
  307.     {
  308.         ColorChat( id, "Everyone's ^3mutes^1 on you has been ^3removed^1." )
  309.  
  310.         for( new i = 1; i <= get_maxplayers(); i++ )
  311.         {
  312.             //-------------------- If the player is not connected or bot or hltv --------------------//
  313.             if( !is_user_connected( i ) || is_user_bot( i ) || is_user_hltv( i ) ) continue
  314.  
  315.             mutesystem[ i ][ id ][ VOICE ] = false
  316.             mutesystem[ i ][ id ][ CHAT ] = false
  317.             mutesystem[ i ][ id ][ ASKFOR ] = false
  318.             muteall[ i ] = false
  319.         }
  320.     }
  321.  
  322.     if( item == 2 ) return showmutes( id )                  // Show who has mute who
  323.     if( item == 3 ) return showmutesforothers( id )         // Put mute for others
  324.  
  325.     return adminmenu( id )
  326. }
  327.  
  328. //-------------------- Show players mute menu --------------------//
  329. public showmutes( id )
  330. {
  331.     //-------------------- Access to the menu & to prevent heap low --------------------//
  332.     if( ~get_user_flags( id ) & ACCESS_ADMIN || !is_user_connected( id ) ) return 0
  333.  
  334.     new data[ 6 ], menu = menu_create( fmt( "\r[\w %s \r]\w show players that mute someone", Prefix ), "sub_showmutes" )
  335.  
  336.     for( new i = 1; i <= get_maxplayers(); i++ )
  337.     {
  338.         //-------------------- If the player is not connected or bot or hltv --------------------//
  339.         if( !is_user_connected( i ) || is_user_bot( i ) || is_user_hltv( i ) ) continue
  340.  
  341.         for( new j = 1; j <= get_maxplayers(); j++ )
  342.         {
  343.             //-------------------- If the player is not connected or yourself or not have mute on someone or bot or hltv --------------------//
  344.             if( !is_user_connected( j ) || is_user_bot( j ) || is_user_hltv( j ) || ( !mutesystem[ i ][ j ][ VOICE ] && !mutesystem[ i ][ j ][ CHAT ] ) || i == j ) continue
  345.  
  346.             num_to_str( i, data, charsmax( data ) )
  347.             menu_additem( menu, fmt( "%n", i ), data )
  348.         }
  349.     }
  350.  
  351.     //-------------------- Previous / Next / Exit --------------------//
  352.     menu_setprop( menu, MPROP_BACKNAME, "previous page" )
  353.     menu_setprop( menu, MPROP_NEXTNAME, "next page" )
  354.     menu_setprop( menu, MPROP_EXITNAME, "back" )
  355.  
  356.     menu_display( id, menu )
  357.     return 1
  358. }
  359.  
  360. public sub_showmutes( id, menu, item )
  361. {
  362.     if( item == MENU_EXIT ) return adminmenu( id )
  363.  
  364.     new data[ 6 ]
  365.     menu_item_getinfo( menu, item, _, data, charsmax( data ) )
  366.  
  367.     return adminremember[ id ] = str_to_num( data ), showplayermutes( id, 0 )
  368. }
  369.  
  370. //-------------------- Show players mutes --------------------//
  371. public showplayermutes( id, page )
  372. {
  373.     //-------------------- Access to the menu & to prevent heap low --------------------//
  374.     if( ~get_user_flags( id ) & ACCESS_ADMIN || !is_user_connected( id ) ) return 0
  375.  
  376.     new data[ 6 ], menu = menu_create( fmt( "\r[\w %s \r]\w show \r%n\w mutes", Prefix, adminremember[ id ] ), "sub_showplayermutes" )
  377.  
  378.     for( new i = 1, counter = -1; i <= get_maxplayers(); i++ )
  379.     {
  380.         //-------------------- If the player is not connected or not have mute on someone or bot or hltv --------------------//
  381.         if( !is_user_connected( i ) || is_user_bot( i ) || is_user_hltv( i ) || ( !mutesystem[ adminremember[ id ] ][ i ][ VOICE ] && !mutesystem[ adminremember[ id ] ][ i ][ CHAT ] ) ) continue
  382.  
  383.         if( ++counter % 6 == 0 ) menu_additem( menu, fmt( "remove \r%n's\w mutes^n", adminremember[ id ] ) )
  384.  
  385.         num_to_str( i, data, charsmax( data ) )
  386.  
  387.         menu_additem( menu, fmt( "%n \r[\w %s%s%s \r]", i, mutesystem[ adminremember[ id ] ][ i ][ VOICE ] ? "Voice" : "",
  388.         mutesystem[ adminremember[ id ] ][ i ][ VOICE ] && mutesystem[ adminremember[ id ] ][ i ][ CHAT ] ? " \y&\w " : "",
  389.         mutesystem[ adminremember[ id ] ][ i ][ CHAT ] ? "Chat" : "" ), data )
  390.     }
  391.  
  392.     //-------------------- Previous / Next / Exit --------------------//
  393.     menu_setprop( menu, MPROP_BACKNAME, "previous page" )
  394.     menu_setprop( menu, MPROP_NEXTNAME, "next page" )
  395.     menu_setprop( menu, MPROP_EXITNAME, "back" )
  396.  
  397.     menu_display( id, menu, page )
  398.     return 1
  399. }
  400.  
  401. public sub_showplayermutes( id, menu, item )
  402. {
  403.     if( item == MENU_EXIT ) return showmutes( id )
  404.  
  405.     new data[ 6 ], page
  406.     menu_item_getinfo( menu, item, _, data, charsmax( data ) )
  407.     player_menu_info( id, menu, menu, page )
  408.  
  409.     new player = str_to_num( data )
  410.  
  411.     //-------------------- If the player is not connected --------------------//
  412.     if( !is_user_connected( player ) ) return ColorChat( id, "^3%n^1 is no longer connected.", player ), showplayermutes( id, page )
  413.  
  414.     //-------------------- Remove all his mutes --------------------//
  415.     if( item % 7 == 0 )
  416.     {
  417.         for( new i = 1; i <= get_maxplayers(); i++ )
  418.         {
  419.             //-------------------- If the player is not connected or bot or hltv --------------------//
  420.             if( !is_user_connected( i ) || is_user_bot( i ) || is_user_hltv( i ) ) continue
  421.  
  422.             mutesystem[ adminremember[ id ] ][ i ][ VOICE ] = false
  423.             mutesystem[ adminremember[ id ] ][ i ][ CHAT ] = false
  424.             mutesystem[ adminremember[ id ] ][ i ][ ASKFOR ] = false
  425.             muteall[ adminremember[ id ] ] = false
  426.         }
  427.  
  428.         return adminmenu( id )
  429.     }
  430.  
  431.     //-------------------- Remove specific mute from him --------------------//
  432.     mutesystem[ adminremember[ id ] ][ player ][ VOICE ] = false
  433.     mutesystem[ adminremember[ id ] ][ player ][ CHAT ] = false
  434.     mutesystem[ adminremember[ id ] ][ player ][ ASKFOR ] = false
  435.     muteall[ adminremember[ id ] ] = false
  436.  
  437.     return showplayermutes( id, page )
  438. }
  439.  
  440. //-------------------- Show players for mute others --------------------//
  441. public showmutesforothers( id )
  442. {
  443.     //-------------------- Access to the menu & to prevent heap low --------------------//
  444.     if( ~get_user_flags( id ) & ACCESS_ADMIN || !is_user_connected( id ) ) return 0
  445.  
  446.     new data[ 6 ], menu = menu_create( fmt( "\r[\w %s \r]\w show players to mute someone for them", Prefix ), "sub_showmutesforothers" )
  447.  
  448.     for( new i = 1; i <= get_maxplayers(); i++ )
  449.     {
  450.         //-------------------- If the player is not connected or bot or hltv --------------------//
  451.         if( !is_user_connected( i ) || is_user_bot( i ) || is_user_hltv( i ) ) continue
  452.  
  453.         num_to_str( i, data, charsmax( data ) )
  454.         menu_additem( menu, fmt( "%n", i ), data )
  455.     }
  456.  
  457.     //-------------------- Previous / Next / Exit --------------------//
  458.     menu_setprop( menu, MPROP_BACKNAME, "previous page" )
  459.     menu_setprop( menu, MPROP_NEXTNAME, "next page" )
  460.     menu_setprop( menu, MPROP_EXITNAME, "back" )
  461.  
  462.     menu_display( id, menu )
  463.     return 1
  464. }
  465.  
  466. public sub_showmutesforothers( id, menu, item )
  467. {
  468.     if( item == MENU_EXIT ) return adminmenu( id )
  469.  
  470.     new data[ 6 ]
  471.     menu_item_getinfo( menu, item, _, data, charsmax( data ) )
  472.  
  473.     return adminremember[ id ] = str_to_num( data ), showplayermutesforothers( id )
  474. }
  475.  
  476. //-------------------- Show players mutes --------------------//
  477. public showplayermutesforothers( id )
  478. {
  479.     //-------------------- Access to the menu & to prevent heap low --------------------//
  480.     if( ~get_user_flags( id ) & ACCESS_ADMIN || !is_user_connected( id ) ) return 0
  481.  
  482.     new bool:blockseeothers = true, menu = menu_create( fmt( "\r[\w %s \r]\w mute profile of: \r%n", Prefix, adminremember[ id ] ), "sub_showplayermutesforothers" )
  483.  
  484.     //-------------------- Block "see who muted you" --------------------//
  485.     for( new i = 1; i <= get_maxplayers(); i++ ) if( mutesystem[ i ][ adminremember[ id ] ][ VOICE ] || mutesystem[ i ][ adminremember[ id ] ][ CHAT ] ) blockseeothers = false
  486.  
  487.     menu_additem( menu, "voice" )
  488.     menu_additem( menu, "chat^n" )
  489.  
  490.     menu_additem( menu, fmt( "%smute everyone^n", muteall[ adminremember[ id ] ] ? "un" : "" ) )
  491.  
  492.     blockseeothers ? menu_addtext2( menu, "\r4. \dsee who muted him" ) : menu_additem( menu, "see who muted him" )
  493.  
  494.     menu_setprop( menu, MPROP_EXITNAME, "back" )
  495.     menu_display( id, menu )
  496.     return 1
  497. }
  498.  
  499. public sub_showplayermutesforothers( id, menu, item )
  500. {
  501.     if( item == MENU_EXIT ) return showmutesforothers( id )
  502.  
  503.     if( item == 0 ) sortmenu[ id ] = true           // Change the menu to voice
  504.     if( item == 1 ) sortmenu[ id ] = false          // Change the menu to chat
  505.     if( item == 2 )                                 // Mute everyone
  506.     {
  507.         muteall[ adminremember[ id ] ] ^= true
  508.         ColorChat( id, "You've ^3%smuted^1 everyone for ^3%n^1.", muteall[ adminremember[ id ] ] ? "" : "un", adminremember[ id ] )
  509.  
  510.         for( new i = 1; i <= get_maxplayers(); i++ )
  511.         {
  512.             //-------------------- If the player is not connected or bot or hltv or yourself --------------------//
  513.             if( !is_user_connected( i ) || is_user_bot( i ) || is_user_hltv( i ) || i == adminremember[ id ] ) continue
  514.  
  515.             mutesystem[ adminremember[ id ] ][ i ][ VOICE ] = muteall[ adminremember[ id ] ]
  516.             mutesystem[ adminremember[ id ] ][ i ][ CHAT ] = muteall[ adminremember[ id ] ]
  517.             mutesystem[ adminremember[ id ] ][ i ][ ASKFOR ] = false
  518.         }
  519.  
  520.         return showplayermutesforothers( id )
  521.     }
  522.     if( item == 3 ) return whomutehim( id, 0 )          // See who mute you
  523.  
  524.     return mutemenuforothers( id, 0 )
  525. }
  526.  
  527. //-------------------- Mute chat/voice menu --------------------//
  528. public mutemenuforothers( id, page )
  529. {
  530.     //-------------------- Access to the menu & to prevent heap low --------------------//
  531.     if( ~get_user_flags( id ) & ACCESS_ADMIN || !is_user_connected( id ) ) return 0
  532.  
  533.     new data[ 6 ], menu = menu_create( fmt( "\r[\w %s \r]\w mute %s for \r%n", Prefix, sortmenu[ id ] ? "voice" : "chat", adminremember[ id ] ), "sub_mutemenuforothers" )
  534.  
  535.     for( new i = 1; i <= get_maxplayers(); i++ )
  536.     {
  537.         //-------------------- If the player is not connected or bot or hltv or the chosen player --------------------//
  538.         if( !is_user_connected( i ) || is_user_bot( i ) || is_user_hltv( i ) || i == adminremember[ id ] ) continue
  539.  
  540.         num_to_str( i, data, charsmax( data ) )
  541.  
  542.         menu_additem( menu, fmt( "%n \d%s", i, ( sortmenu[ id ] && mutesystem[ adminremember[ id ] ][ i ][ VOICE ] )
  543.         || ( !sortmenu[ id ] && mutesystem[ adminremember[ id ] ][ i ][ CHAT ] ) ? "- [\r muted \d]" : "" ), data )
  544.     }
  545.  
  546.     //-------------------- Previous / Next / Exit --------------------//
  547.     menu_setprop( menu, MPROP_BACKNAME, "previous page" )
  548.     menu_setprop( menu, MPROP_NEXTNAME, "next page" )
  549.     menu_setprop( menu, MPROP_EXITNAME, "back" )
  550.  
  551.     menu_display( id, menu, page )
  552.     return 1
  553. }
  554.  
  555. public sub_mutemenuforothers( id, menu, item )
  556. {
  557.     if( item == MENU_EXIT ) return showplayermutesforothers( id )
  558.  
  559.     new data[ 6 ], page
  560.     menu_item_getinfo( menu, item, _, data, charsmax( data ) )
  561.     player_menu_info( id, menu, menu, page )
  562.  
  563.     new player = str_to_num( data )
  564.  
  565.     //-------------------- If the player is not connected --------------------//
  566.     if( !is_user_connected( player ) ) return ColorChat( id, "^3%n^1 is no longer connected.", player ), mutemenuforothers( id, page )
  567.  
  568.     if( sortmenu[ id ] )
  569.     {
  570.         mutesystem[ adminremember[ id ] ][ player ][ VOICE ] = !mutesystem[ adminremember[ id ] ][ player ][ VOICE ]
  571.         ColorChat( id, mutesystem[ adminremember[ id ] ][ player ][ VOICE ] ? "^3%n^1 canno't hear ^3%n^1 until he will remove his mute." : "^3%n^1 can hear ^3%n^1 now.", adminremember[ id ], player )
  572.     }
  573.     else if( !sortmenu[ id ] )
  574.     {
  575.         mutesystem[ adminremember[ id ] ][ player ][ CHAT ] = !mutesystem[ adminremember[ id ] ][ player ][ CHAT ]
  576.         ColorChat( id, mutesystem[ adminremember[ id ] ][ player ][ CHAT ] ? "^3%n^1 canno't see what ^3%n^1 write until he will remove his mute." : "^3%n^1 can see what ^3%n^1 write now.", adminremember[ id ], player )
  577.     }
  578.  
  579.     //-------- If there is even a single player he didnt mute on ( voice / chat ) turn the "Mute everyone" off ------------//
  580.     for( new i = 1; i <= get_maxplayers(); i++ ) if( !mutesystem[ adminremember[ id ] ][ i ][ VOICE ] && !mutesystem[ adminremember[ id ] ][ i ][ VOICE ] ) muteall[ adminremember[ id ] ] = false
  581.  
  582.     //-------- If the player that you muted has asked you to remove his mute it will remove his block ------------//
  583.     mutesystem[ adminremember[ id ] ][ player ][ ASKFOR ] = false
  584.  
  585.     return mutemenuforothers( id, page )
  586. }
  587.  
  588. //-------------------- See who mute him --------------------//
  589. public whomutehim( id, page )
  590. {
  591.     //-------------------- Access to the menu & to prevent heap low --------------------//
  592.     if( ~get_user_flags( id ) & ACCESS_ADMIN || !is_user_connected( id ) ) return 0
  593.  
  594.     new item[ 256 ], data[ 6 ]
  595.  
  596.     formatex( item, charsmax( item ), "\r[\w %s \r]\w see who muted \r%n", Prefix, adminremember[ id ] )
  597.     new menu = menu_create( item, "sub_whomutehim" )
  598.  
  599.     for( new i = 1; i <= get_maxplayers(); i++ )
  600.     {
  601.         //-------------------- If the player is not connected or not have mute on someone or bot or hltv --------------------//
  602.         if( !is_user_connected( i ) || is_user_bot( i ) || is_user_hltv( i )
  603.         || ( !mutesystem[ i ][ adminremember[ id ] ][ VOICE ] && !mutesystem[ i ][ adminremember[ id ] ][ CHAT ] ) ) continue
  604.  
  605.         num_to_str( i, data, charsmax( data ) )
  606.  
  607.         formatex( item, charsmax( item ), "%n \r[\w %s%s%s \r]", i, mutesystem[ i ][ adminremember[ id ] ][ VOICE ] ? "Voice" : "",
  608.         mutesystem[ i ][ adminremember[ id ] ][ VOICE ] && mutesystem[ i ][ adminremember[ id ] ][ CHAT ] ? " \y&\w " : "",
  609.         mutesystem[ i ][ adminremember[ id ] ][ CHAT ] ? "Chat" : "" )
  610.         menu_additem( menu, item, data )
  611.     }
  612.  
  613.     //-------------------- Previous / Next / Exit --------------------//
  614.     menu_setprop( menu, MPROP_BACKNAME, "previous page" )
  615.     menu_setprop( menu, MPROP_NEXTNAME, "next page" )
  616.     menu_setprop( menu, MPROP_EXITNAME, "back" )
  617.  
  618.     menu_display( id, menu, page )
  619.     return 1
  620. }
  621.  
  622. public sub_whomutehim( id, menu, item )
  623. {
  624.     if( item == MENU_EXIT ) return showplayermutesforothers( id )
  625.  
  626.     new data[ 6 ], page
  627.     menu_item_getinfo( menu, item, _, data, charsmax( data ) )
  628.     player_menu_info( id, menu, menu, page )
  629.  
  630.     new player = str_to_num( data )
  631.  
  632.     //-------------------- If the player is not connected --------------------//
  633.     if( !is_user_connected( player ) ) return ColorChat( id, "^3%n^1 is no longer connected.", player ), showplayermutesforothers( id )
  634.  
  635.     mutesystem[ player ][ adminremember[ id ] ][ VOICE ] = false
  636.     mutesystem[ player ][ adminremember[ id ] ][ CHAT ] = false
  637.     mutesystem[ player ][ adminremember[ id ] ][ ASKFOR ] = false
  638.     muteall[ player ] = false
  639.  
  640.     ColorChat( id, "You removed ^3%n's^1 mute from ^3%n^1.", adminremember[ id ], player )
  641.     return whomutehim( id, page )
  642. }
  643.  
  644. //-------------------- Stocks - ColorChat --------------------//
  645. stock ColorChat( id, const string[], any:... )
  646. {
  647.     new msg[ 191 ], len = formatex( msg, charsmax( msg ), "^3[^1 %s ^3]^1 ", Prefix )
  648.     vformat( msg[ len ], charsmax( msg ) - len, string, 3 )
  649.  
  650.     client_print_color( id, print_team_default, msg )
  651.     return 1
  652. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement