Advertisement
RanAway

[ Pawn ] advanced mute menu

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