Advertisement
ISRaiyaN

Admin Chat - New

Feb 14th, 2019
149
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 0.80 KB | None | 0 0
  1. #include < amxmodx >
  2.  
  3. #define LOG
  4.  
  5. new Prefix[] = "AMXX"
  6.  
  7. new g_szAdminChat[ 200 ][ 32 ];
  8. new name[200];
  9.  
  10.  
  11. new bool:inchat[33]
  12.  
  13. enum _:AGroups
  14. {
  15.         Name[12],
  16.         R,
  17.         G,
  18.         B,
  19.         Effect,
  20.         Flag
  21. }
  22.  
  23. new const szGroups[ ][ AGroups ] = {
  24.         { "Owner", 0, 0, 0, 1, ADMIN_IMMUNITY },
  25.         { "Manager", 0, 127, 255, 1, ADMIN_RESERVATION },
  26.         { "Super Admin", 255, 127, 0, 0, ADMIN_LEVEL_C },
  27.         { "Admin", 0, 255, 127, 0, ADMIN_BAN },
  28.         { "VIP", 255, 255, 255, 0, ADMIN_KICK },
  29.         { "Premium", 250, 255, 250, 255, ADMIN_LEVEL_F }
  30. }
  31.  
  32. new Float: g_flPositions[ 2 ][ 4 ][ 2 ] = {
  33.         {
  34.                 { 0.07, 0.57 },
  35.                 { 0.07, 0.60 },
  36.                 { 0.07, 0.63 },
  37.                 { 0.07, 0.66 }
  38.         },
  39.         {
  40.                 { -1.0, 0.10 },
  41.                 { -1.0, 0.13 },
  42.                 { -1.0, 0.16 },
  43.                 { -1.0, 0.19 }
  44.         }
  45. }
  46.  
  47. new g_iHudPosition, Float: g_flLastTsay[ 33 ]
  48.  
  49. #if defined LOG
  50. new szLogFile[ 24 ];
  51. #endif
  52.  
  53. public plugin_init() {
  54.         register_plugin( "Admin Chat Colored", "v2.1", "+ColdWar Edited By ISRaiyaN" );
  55.        
  56.         register_clcmd( "say", "ClCmd_SayHook" );
  57.    
  58.     register_clcmd("say /chat","ShowAdminChatMenu" );
  59.     register_clcmd("admin_name", "ChatName" );
  60.     register_clcmd("remove_chat", "RemoveName" );
  61.  
  62.        
  63.         #if defined LOG
  64.         get_time( "AdminChat-%y%m%d.log", szLogFile, sizeof szLogFile - 1 );
  65.         #endif
  66. }
  67.  
  68. public ShowAdminChatMenu(id)
  69. {
  70.     if( !( get_user_flags( id ) & ADMIN_CHAT ) )
  71.     {
  72.         ColorChat( id, "^4[ ^3%s ^4] ^1You ^4Don't ^1have ^3Access ^1to this ^4Command.", Prefix )
  73.         return 1;
  74.     }
  75.     new Text[2000]
  76.    
  77.     formatex(Text,charsmax(Text),"\r[\d %s \r]\w AdminChat Menu \yBy ISRaiyaN^n^n\r- \dAdminChat Name: \r[ \y%s \r] ",Prefix, g_szAdminChat[name[id]])
  78.     new iMenu = menu_create(Text, "AdminChat_Handler")
  79.    
  80.     formatex(Text, charsmax(Text), "Change \yAdminChat Name^n",g_szAdminChat[name[id]])
  81.     menu_additem(iMenu, Text, "0")
  82.    
  83.     menu_additem(iMenu, "Remove \yAdminChat Name^n^n", "1")
  84.    
  85.     menu_setprop( iMenu, MPROP_NUMBER_COLOR, "\r" );
  86.     menu_display(id, iMenu)
  87.  
  88.     return 1;
  89. }
  90. public AdminChat_Handler(id, iMenu, item)
  91. {
  92.     switch(item)
  93.     {
  94.         case 0:
  95.         {
  96.             client_cmd( id, "messagemode admin_name" );
  97.             ShowAdminChatMenu( id )
  98.         }
  99.         case 1:
  100.         {
  101.             client_cmd( id, "remove_chat" );
  102.             ShowAdminChatMenu( id )
  103.         }
  104.     }
  105. }          
  106.            
  107. public ChatName( id )
  108. {
  109.     if( !( get_user_flags( id ) & ADMIN_CHAT ) )
  110.     {
  111.         ColorChat( id, "^4[ ^3%s ^4] ^1You ^4Don't ^1have ^3Access ^1to this ^4Command.", Prefix )
  112.         return 1;
  113.     }
  114.    
  115.     new szArgs[ 60 ];
  116.     read_args( szArgs, charsmax( szArgs ) );
  117.     remove_quotes( szArgs );
  118.    
  119.     ColorChat( id, "^4[ ^3%s ^4] ^1Your ^4AdminChat ^1Name: ^3%s^1", Prefix, szArgs)
  120.    
  121.     inchat[id] = true
  122.    
  123.     name[id] = id
  124.    
  125.     copy( g_szAdminChat[ id ], charsmax( g_szAdminChat[ ] ), szArgs )
  126.    
  127.     ShowAdminChatMenu(id)
  128.    
  129.     return 1;
  130. }
  131.  
  132. public RemoveName( id )
  133. {
  134.     if( !( get_user_flags( id ) & ADMIN_CHAT ) )
  135.     {
  136.         ColorChat( id, "^4[ ^3%s ^4] ^1You ^4Don't ^1have ^3Access ^1to this ^4Command.", Prefix )
  137.         return 1;
  138.     }
  139.  
  140.     if( inchat[id])
  141.     {
  142.         ColorChat( id, "^4[ ^3%s ^4] ^1You have ^3Removed ^1your ^4AdminChat Name^1 ", Prefix)
  143.  
  144.         inchat[id] = false
  145.        
  146.         ShowAdminChatMenu(id)
  147.    
  148.         return 1;
  149.     }
  150.     else
  151.     {
  152.         ColorChat( id, "^4[ ^3%s ^4] ^1Your ^3AdminChat Name^1 is ^4Already Removed.", Prefix)
  153.  
  154.         inchat[id] = false
  155.    
  156.         return 1;
  157.     }
  158.     return 0;
  159. }
  160.  
  161.  
  162. public ClCmd_SayHook( id )
  163. {
  164.         new szMessage[ 192 ];
  165.         read_argv( 1, szMessage, sizeof szMessage - 1 );
  166.        
  167.         remove_quotes( szMessage );
  168.         trim( szMessage );
  169.        
  170.         if( !( get_user_flags( id ) & ADMIN_CHAT ) )
  171.                 return 0;      
  172.         else if( !StartWith( szMessage, "@" ) )
  173.                 return 0;
  174.         else if( get_gametime( ) - g_flLastTsay[ id ] < 1.0 )
  175.         {
  176.                 ColorChat( id, "^4[ ^3%s ^4]^1 You need to wait more ^4%.1f^1 to use ^3Admin Chat^1.", Prefix, 0.5 - ( get_gametime( ) - g_flLastTsay[ id ] ) )
  177.                 return 1;
  178.         }
  179.         else
  180.         {
  181.                 new g_iPos = StartWith( szMessage, "@@" );
  182.                
  183.                 replace( szMessage, sizeof szMessage - 1, g_iPos ? "@@" : "@", "" );
  184.                
  185.                 if( !strlen( szMessage ) )
  186.                         return 1;
  187.                        
  188.                 new szName[ 32 ], groupid;
  189.                
  190.                 get_user_name( id, szName, sizeof szName- 1 );
  191.                 groupid = GetGroupID( get_user_flags( id ) );
  192.                
  193.                 if( !szGroups[ groupid ][ R ] && !szGroups[ groupid ][ G ] && !szGroups[ groupid ][ B ] )
  194.                         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 );
  195.                 else
  196.                         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 );
  197.                
  198.                 replace_all( szMessage, sizeof szMessage - 1, "%n", "^n" );
  199.        
  200.         if(! inchat[id])
  201.         show_hudmessage( 0, "[ %s ] %s :  %s", szGroups[ groupid ][ Name ], szName, szMessage );
  202.        
  203.         else
  204.  
  205.         show_hudmessage( 0, "[ %s ] %s :  %s", g_szAdminChat[name[id]], szName, szMessage );
  206.                
  207.                 replace_all( szMessage, sizeof szMessage - 1, "^n", " " );
  208.                
  209.         if(! inchat[id])
  210.         ColorChat( 0, "^4[ ^3%s ^4] ^3%s^1 :  ^4%s", szGroups[ groupid ][ Name ], szName, szMessage )
  211.        
  212.         else
  213.        
  214.         ColorChat( 0, "^4[ ^3%s ^4] ^3%s^1 :  ^4%s", g_szAdminChat[name[id]], szName, szMessage )
  215.        
  216.        
  217.                 #if defined LOG
  218.                 new auth[ 35 ], ip[ 26 ];
  219.                
  220.                 get_user_authid( id, auth, sizeof auth - 1 );
  221.                 get_user_ip( id, ip, sizeof ip - 1, 1 );
  222.                
  223.                 log_to_file( szLogFile, "[%s] %s < %s >< %s > says: %s.", szGroups[ groupid ][ Name ], szName, auth, ip, szMessage );
  224.                 #endif
  225.                
  226.                
  227.                 g_iHudPosition ++;
  228.                
  229.                 g_flLastTsay[ id ] = get_gametime( );
  230.                
  231.                 if( g_iHudPosition > 3 )
  232.                         g_iHudPosition = 0;
  233.                
  234.                 return 1;
  235.         }
  236.         return 0;
  237. }
  238.  
  239. stock StartWith( Msg[ ], Msg2[ ] )
  240. {
  241.         return( equal( Msg, Msg2, strlen( Msg2 ) ) );
  242. }
  243.  
  244. stock GetGroupID( flags )
  245. {
  246.         for( new i = 0 ; i < sizeof szGroups ; i ++ )
  247.         {
  248.                 if( flags & szGroups[ i ][ Flag ] )
  249.                         return i;
  250.         }
  251.         return -1;
  252. }
  253.  
  254. stock ColorChat( index, message[], any:... )
  255. {
  256.         if( index && !is_user_connected( index ) || !index && !get_playersnum( ) )
  257.                 return 0;
  258.                
  259.         static szMessage[ 242 ];
  260.        
  261.         vformat( szMessage, charsmax( szMessage ), message, 3 );
  262.        
  263.         static st_msgid;
  264.         if( !st_msgid )
  265.                 st_msgid = get_user_msgid( "SayText" );
  266.                
  267.         if( index )
  268.         {
  269.                 message_begin( MSG_ONE_UNRELIABLE, st_msgid, _, index );
  270.                 write_byte( index );
  271.                 write_string( szMessage );
  272.                 message_end( );
  273.         }
  274.         else
  275.         {
  276.                
  277.                 static cc_glb_maxids;
  278.                 if( !cc_glb_maxids )
  279.                         cc_glb_maxids = get_maxplayers( );
  280.                        
  281.                 for( index = 1 ; index <= cc_glb_maxids ; index ++ )
  282.                 {
  283.                         if( !is_user_connected( index ) )
  284.                                 continue;
  285.                                
  286.                         message_begin( MSG_ONE_UNRELIABLE, st_msgid, _, index );
  287.                         write_byte( index );
  288.                         write_string( szMessage );
  289.                         message_end( );
  290.                 }
  291.         }
  292.         return 1;
  293. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement