Advertisement
Rejack

Admins Online (v1.1)

Jul 24th, 2013 (edited)
1,108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 3.59 KB | None | 0 0
  1. /*
  2.     * Description:
  3.         When a player write for example: /admins
  4.         It will show all the online admins on the server sort by access level.
  5.    
  6.     * Credit:
  7.         Rejack
  8.    
  9.     * Change Log:
  10.         * v1.0: First built the plugin.
  11.         * v1.1:
  12.             * Added Cvars to:
  13.                 - Disable or Enable the plugin.
  14.                 - Change between ColorChat msg to Hud msg.
  15.  
  16. */
  17.  
  18. #include < amxmodx >
  19.  
  20. enum _:g_mData
  21. {
  22.     g_mName[ 32 ],
  23.     g_mAccess
  24. };
  25.  
  26. #define WITH_SUPER_ADMIN
  27.  
  28. new const szAdmin[ ][ g_mData ] =
  29. {
  30.     { "Owner", ADMIN_RCON },
  31.     { "Manager", ADMIN_IMMUNITY },
  32.    
  33.     #if defined WITH_SUPER_ADMIN
  34.     { "Super Admin", ADMIN_BAN },
  35.     #endif
  36.    
  37.     { "Admin", ADMIN_KICK },
  38.     { "VIP", ADMIN_SLAY }
  39. };
  40.  
  41. new const szPrefix[] = "^4[AMXX]^1";
  42.  
  43. new pCvar[ 2 ];
  44.  
  45. public plugin_init()
  46. {
  47.     register_plugin( "Admins Online", "1.1", "Rejack" );
  48.    
  49.     register_saycmd( "admin", "CmdAdmins" );
  50.     register_saycmd( "admins", "CmdAdmins" );
  51.    
  52.     pCvar[ 0 ] = register_cvar( "admins_online", "1" );
  53.     pCvar[ 1 ] = register_cvar( "admins_message", "0" );        /* 0 = Chat | 1 = Hudmessage */
  54. }
  55.  
  56. public CmdAdmins( client )
  57. {
  58.     if ( !get_pcvar_num( pCvar[ 0 ] ) )
  59.         return 1;
  60.    
  61.     new szText[ 128 ], szMsg[ 512 ], szString[ 2048 ], szOnline[ 512 ], g_iCount, szName[ 32 ], bool: bInContent[ 33 ];static Cvar;
  62.    
  63.     Cvar = get_pcvar_num( pCvar[ 1 ] );
  64.    
  65.     for ( new j; j < sizeof szAdmin; j++ )
  66.     {
  67.         g_iCount = 0;
  68.        
  69.         szOnline = "";
  70.        
  71.         for ( new i = 1; i < get_maxplayers(); i++ )
  72.         {
  73.             if ( !is_user_connected( i ) || !( get_user_flags( i ) & szAdmin[ j ][ g_mAccess ] ) ||  bInContent[ i ] )
  74.                 continue;
  75.            
  76.             bInContent[ i ] = true;
  77.            
  78.             get_user_name( i, szName, 31 );
  79.            
  80.             if ( !Cvar )
  81.                 formatex( szText, charsmax( szText ), "%s^4%s", (g_iCount > 0 ) ? "^3. " : "", szName );
  82.            
  83.             else
  84.                 formatex( szText, charsmax( szText ), "%s%s", (g_iCount > 0) ? ", " : "", szName );
  85.            
  86.             add( szOnline, charsmax( szOnline ), szText );
  87.            
  88.             g_iCount++;
  89.         }
  90.        
  91.         if ( !g_iCount )
  92.         {
  93.             if ( !Cvar )
  94.                 ColorPrint( client, "^3No^4 %s's^3 Online^1.", szAdmin[ j ] );
  95.                
  96.             else
  97.                 formatex( szMsg, charsmax( szMsg ), "No %s's Online.^n", szAdmin[ j ] );
  98.         }
  99.            
  100.        
  101.         else
  102.         {
  103.             if ( !Cvar )
  104.                 ColorPrint( client, "^3Online^4 %s's^1: %s^1.", szAdmin[ j ], szOnline );
  105.            
  106.             else
  107.                 formatex( szMsg, charsmax( szMsg ), "Online %s's: %s.^n", szAdmin[ j ], szOnline );
  108.         }
  109.        
  110.         if ( Cvar != 0 )
  111.             add( szString, charsmax( szString ), szMsg );
  112.     }
  113.    
  114.     if ( !Cvar )
  115.         return 1;
  116.    
  117.     set_hudmessage( 255, 0, 0, 0.03, -1.0, 1, 0.0, 8.0, 0.1, 0.1, -1 );
  118.    
  119.     show_hudmessage( client, szString );
  120.    
  121.     return 1;
  122. }
  123.  
  124. stock ColorPrint( const client, const string[], any:... )
  125. {
  126.     new szMsg[ 191 ], Players[ 32 ], PNum = 1;
  127.    
  128.     static iLen; iLen = formatex( szMsg, charsmax( szMsg ), "%s ", szPrefix );
  129.    
  130.     vformat( szMsg[ iLen ], charsmax( szMsg ) - iLen, string, 3 );
  131.    
  132.     if ( client )
  133.         Players[ 0 ] = client;
  134.    
  135.     else
  136.         get_players( Players, PNum, "ch" );
  137.    
  138.     for ( new i; i < PNum; i++ )
  139.     {
  140.         if( is_user_connected( Players[ i ] ) )
  141.         {
  142.             message_begin( MSG_ONE_UNRELIABLE, get_user_msgid( "SayText" ), _, Players[ i ] );
  143.            
  144.             write_byte( Players[ i ] );
  145.            
  146.             write_string( szMsg );
  147.            
  148.             message_end( );
  149.         }
  150.     }
  151.    
  152.     return 1;
  153. }
  154.  
  155. stock register_saycmd( szCommand[], szHandler[] )
  156. {
  157.     new szSayType[][] = { "say", "say_team" }, szSigns[][] = { "/", "!", "." }, szSayItem[ 128 ];
  158.    
  159.     for ( new i; i < sizeof szSayType; i++ )
  160.     {
  161.         for ( new j; j < sizeof szSigns; j++ )
  162.         {
  163.             formatex( szSayItem, 127, "%s %s%s", szSayType[ i ], szSigns[ j ], szCommand );
  164.            
  165.             register_clcmd( szSayItem, szHandler );
  166.         }
  167.     }
  168. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement