Advertisement
ColdWar-Pawn

Admin Chat | Colored

Apr 22nd, 2013
3,597
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 4.23 KB | None | 0 0
  1. /* Plugin generated by AMXX-Studio */
  2.  
  3. #include < amxmodx >
  4.  
  5. #define LOG
  6.  
  7. enum _:AGroups
  8. {
  9.     Name[12],
  10.     R,
  11.     G,
  12.     B,
  13.     Effect,
  14.     Flag
  15. }
  16.  
  17. new const szGroups[ ][ AGroups ] = {
  18.     { "Owner", 0, 0, 0, 1, ADMIN_IMMUNITY },
  19.     { "Manager", 0, 127, 255, 1, ADMIN_RESERVATION },
  20.     { "Super Admin", 255, 127, 0, 0, ADMIN_LEVEL_C },
  21.     { "Admin", 0, 255, 127, 0, ADMIN_BAN },
  22.     { "VIP", 255, 255, 255, 0, ADMIN_CHAT }
  23. }
  24.  
  25. new Float: g_flPositions[ 2 ][ 4 ][ 2 ] = {
  26.     {
  27.         { 0.07, 0.57 },
  28.         { 0.07, 0.60 },
  29.         { 0.07, 0.63 },
  30.         { 0.07, 0.66 }
  31.     },
  32.     {
  33.         { -1.0, 0.10 },
  34.         { -1.0, 0.13 },
  35.         { -1.0, 0.16 },
  36.         { -1.0, 0.19 }
  37.     }
  38. }
  39.  
  40. new g_iHudPosition, Float: g_flLastTsay[ 33 ]
  41.  
  42. #if defined LOG
  43. new szLogFile[ 24 ];
  44. #endif
  45.  
  46. public plugin_init() {
  47.     register_plugin( "Admin Chat Colored", "v2.0", "+ColdWar" );
  48.    
  49.     register_clcmd( "say", "ClCmd_SayHook" );
  50.    
  51.     #if defined LOG
  52.     get_time( "AdminChat-%y%m%d.log", szLogFile, sizeof szLogFile - 1 );
  53.     #endif
  54. }
  55.  
  56. public ClCmd_SayHook( client )
  57. {
  58.     new szMessage[ 192 ];
  59.     read_argv( 1, szMessage, sizeof szMessage - 1 );
  60.    
  61.     remove_quotes( szMessage );
  62.     trim( szMessage );
  63.    
  64.     if( !( get_user_flags( client ) & ADMIN_CHAT ) )
  65.         return 0;  
  66.     else if( !StartWith( szMessage, "@" ) )
  67.         return 0;
  68.     else if( get_gametime( ) - g_flLastTsay[ client ] < 1.0 )
  69.     {
  70.         ColorChat( client, "^4[AMXX]^1 You need to wait more ^4%.1f^1 to use ^3admin chat^1.", 0.5 - ( get_gametime( ) - g_flLastTsay[ client ] ) )
  71.         return 1;
  72.     }
  73.     else
  74.     {
  75.         new g_iPos = StartWith( szMessage, "@@" );
  76.        
  77.         replace( szMessage, sizeof szMessage - 1, g_iPos ? "@@" : "@", "" );
  78.        
  79.         if( !strlen( szMessage ) )
  80.             return 1;
  81.            
  82.         new szName[ 32 ], groupid;
  83.        
  84.         get_user_name( client, szName, sizeof szName- 1 );
  85.         groupid = GetGroupID( get_user_flags( client ) );
  86.        
  87.         if( !szGroups[ groupid ][ R ] && !szGroups[ groupid ][ G ] && !szGroups[ groupid ][ B ] )
  88.             set_hudmessage( random( 256 ), random( 256 ), random( 256 ), g_flPositions[ g_iPos ][ g_iHudPosition ][ 0 ], g_flPositions[ g_iPos ][ g_iHudPosition ][ 1 ], szGroups[ groupid ][ Effect ], 0.0, 12.0, 0.0, 0.0, g_iHudPosition );
  89.         else
  90.             set_hudmessage( szGroups[ groupid ][ R ], szGroups[ groupid ][ G ], szGroups[ groupid ][ B ], g_flPositions[ g_iPos ][ g_iHudPosition ][ 0 ], g_flPositions[ g_iPos ][ g_iHudPosition ][ 1 ], szGroups[ groupid ][ Effect ], 0.0, 12.0, 0.0, 0.0, g_iHudPosition );
  91.        
  92.         replace_all( szMessage, sizeof szMessage - 1, "%n", "^n" );
  93.         show_hudmessage( 0, "[ %s ] %s :  %s", szGroups[ groupid ][ Name ], szName, szMessage );
  94.        
  95.         replace_all( szMessage, sizeof szMessage - 1, "^n", " " );
  96.        
  97.         ColorChat( 0, "^4[ ^1%s ^4] ^3%s^1 :  ^4%s", szGroups[ groupid ][ Name ], szName, szMessage );
  98.        
  99.         #if defined LOG
  100.         new auth[ 35 ], ip[ 26 ];
  101.        
  102.         get_user_authid( client, auth, sizeof auth - 1 );
  103.         get_user_ip( client, ip, sizeof ip - 1, 1 );
  104.        
  105.         log_to_file( szLogFile, "[%s] %s < %s >< %s > says: %s.", szGroups[ groupid ][ Name ], szName, auth, ip, szMessage );
  106.         #endif
  107.        
  108.        
  109.         g_iHudPosition ++;
  110.        
  111.         g_flLastTsay[ client ] = get_gametime( );
  112.        
  113.         if( g_iHudPosition > 3 )
  114.             g_iHudPosition = 0;
  115.        
  116.         return 1;
  117.     }
  118.     return 0;
  119. }
  120.  
  121. stock StartWith( Msg[ ], Msg2[ ] )
  122. {
  123.     return( equal( Msg, Msg2, strlen( Msg2 ) ) );
  124. }
  125.  
  126. stock GetGroupID( flags )
  127. {
  128.     for( new i = 0 ; i < sizeof szGroups ; i ++ )
  129.     {
  130.         if( flags & szGroups[ i ][ Flag ] )
  131.             return i;
  132.     }
  133.     return -1;
  134. }
  135.  
  136. stock ColorChat( index, message[], any:... )
  137. {
  138.     if( index && !is_user_connected( index ) || !index && !get_playersnum( ) )
  139.         return 0;
  140.        
  141.     static szMessage[ 242 ];
  142.    
  143.     vformat( szMessage, charsmax( szMessage ), message, 3 );
  144.    
  145.     static st_msgid;
  146.     if( !st_msgid )
  147.         st_msgid = get_user_msgid( "SayText" );
  148.        
  149.     if( index )
  150.     {
  151.         message_begin( MSG_ONE_UNRELIABLE, st_msgid, _, index );
  152.         write_byte( index );
  153.         write_string( szMessage );
  154.         message_end( );
  155.     }
  156.     else
  157.     {
  158.        
  159.         static cc_glb_maxclients;
  160.         if( !cc_glb_maxclients )
  161.             cc_glb_maxclients = get_maxplayers( );
  162.            
  163.         for( index = 1 ; index <= cc_glb_maxclients ; index ++ )
  164.         {
  165.             if( !is_user_connected( index ) )
  166.                 continue;
  167.                
  168.             message_begin( MSG_ONE_UNRELIABLE, st_msgid, _, index );
  169.             write_byte( index );
  170.             write_string( szMessage );
  171.             message_end( );
  172.         }
  173.     }
  174.     return 1;
  175. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement