Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include < amxmodx >
- #define LOG
- new Prefix[] = "AMXX"
- new g_szAdminChat[ 200 ][ 32 ];
- new name[200];
- new bool:inchat[33]
- enum _:AGroups
- {
- Name[12],
- R,
- G,
- B,
- Effect,
- Flag
- }
- new const szGroups[ ][ AGroups ] = {
- { "Owner", 0, 0, 0, 1, ADMIN_IMMUNITY },
- { "Manager", 0, 127, 255, 1, ADMIN_RESERVATION },
- { "Super Admin", 255, 127, 0, 0, ADMIN_LEVEL_C },
- { "Admin", 0, 255, 127, 0, ADMIN_BAN },
- { "VIP", 255, 255, 255, 0, ADMIN_KICK },
- { "Premium", 250, 255, 250, 255, ADMIN_LEVEL_F }
- }
- new Float: g_flPositions[ 2 ][ 4 ][ 2 ] = {
- {
- { 0.07, 0.57 },
- { 0.07, 0.60 },
- { 0.07, 0.63 },
- { 0.07, 0.66 }
- },
- {
- { -1.0, 0.10 },
- { -1.0, 0.13 },
- { -1.0, 0.16 },
- { -1.0, 0.19 }
- }
- }
- new g_iHudPosition, Float: g_flLastTsay[ 33 ]
- #if defined LOG
- new szLogFile[ 24 ];
- #endif
- public plugin_init() {
- register_plugin( "Admin Chat Colored", "v2.1", "+ColdWar Edited By ISRaiyaN" );
- register_clcmd( "say", "ClCmd_SayHook" );
- register_clcmd("say /chat","ShowAdminChatMenu" );
- register_clcmd("admin_name", "ChatName" );
- register_clcmd("remove_chat", "RemoveName" );
- #if defined LOG
- get_time( "AdminChat-%y%m%d.log", szLogFile, sizeof szLogFile - 1 );
- #endif
- }
- public ShowAdminChatMenu(id)
- {
- if( !( get_user_flags( id ) & ADMIN_CHAT ) )
- {
- ColorChat( id, "^4[ ^3%s ^4] ^1You ^4Don't ^1have ^3Access ^1to this ^4Command.", Prefix )
- return 1;
- }
- new Text[2000]
- 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]])
- new iMenu = menu_create(Text, "AdminChat_Handler")
- formatex(Text, charsmax(Text), "Change \yAdminChat Name^n",g_szAdminChat[name[id]])
- menu_additem(iMenu, Text, "0")
- menu_additem(iMenu, "Remove \yAdminChat Name^n^n", "1")
- menu_setprop( iMenu, MPROP_NUMBER_COLOR, "\r" );
- menu_display(id, iMenu)
- return 1;
- }
- public AdminChat_Handler(id, iMenu, item)
- {
- switch(item)
- {
- case 0:
- {
- client_cmd( id, "messagemode admin_name" );
- ShowAdminChatMenu( id )
- }
- case 1:
- {
- client_cmd( id, "remove_chat" );
- ShowAdminChatMenu( id )
- }
- }
- }
- public ChatName( id )
- {
- if( !( get_user_flags( id ) & ADMIN_CHAT ) )
- {
- ColorChat( id, "^4[ ^3%s ^4] ^1You ^4Don't ^1have ^3Access ^1to this ^4Command.", Prefix )
- return 1;
- }
- new szArgs[ 60 ];
- read_args( szArgs, charsmax( szArgs ) );
- remove_quotes( szArgs );
- ColorChat( id, "^4[ ^3%s ^4] ^1Your ^4AdminChat ^1Name: ^3%s^1", Prefix, szArgs)
- inchat[id] = true
- name[id] = id
- copy( g_szAdminChat[ id ], charsmax( g_szAdminChat[ ] ), szArgs )
- ShowAdminChatMenu(id)
- return 1;
- }
- public RemoveName( id )
- {
- if( !( get_user_flags( id ) & ADMIN_CHAT ) )
- {
- ColorChat( id, "^4[ ^3%s ^4] ^1You ^4Don't ^1have ^3Access ^1to this ^4Command.", Prefix )
- return 1;
- }
- if( inchat[id])
- {
- ColorChat( id, "^4[ ^3%s ^4] ^1You have ^3Removed ^1your ^4AdminChat Name^1 ", Prefix)
- inchat[id] = false
- ShowAdminChatMenu(id)
- return 1;
- }
- else
- {
- ColorChat( id, "^4[ ^3%s ^4] ^1Your ^3AdminChat Name^1 is ^4Already Removed.", Prefix)
- inchat[id] = false
- return 1;
- }
- return 0;
- }
- public ClCmd_SayHook( id )
- {
- new szMessage[ 192 ];
- read_argv( 1, szMessage, sizeof szMessage - 1 );
- remove_quotes( szMessage );
- trim( szMessage );
- if( !( get_user_flags( id ) & ADMIN_CHAT ) )
- return 0;
- else if( !StartWith( szMessage, "@" ) )
- return 0;
- else if( get_gametime( ) - g_flLastTsay[ id ] < 1.0 )
- {
- 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 ] ) )
- return 1;
- }
- else
- {
- new g_iPos = StartWith( szMessage, "@@" );
- replace( szMessage, sizeof szMessage - 1, g_iPos ? "@@" : "@", "" );
- if( !strlen( szMessage ) )
- return 1;
- new szName[ 32 ], groupid;
- get_user_name( id, szName, sizeof szName- 1 );
- groupid = GetGroupID( get_user_flags( id ) );
- if( !szGroups[ groupid ][ R ] && !szGroups[ groupid ][ G ] && !szGroups[ groupid ][ B ] )
- 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 );
- else
- 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 );
- replace_all( szMessage, sizeof szMessage - 1, "%n", "^n" );
- if(! inchat[id])
- show_hudmessage( 0, "[ %s ] %s : %s", szGroups[ groupid ][ Name ], szName, szMessage );
- else
- show_hudmessage( 0, "[ %s ] %s : %s", g_szAdminChat[name[id]], szName, szMessage );
- replace_all( szMessage, sizeof szMessage - 1, "^n", " " );
- if(! inchat[id])
- ColorChat( 0, "^4[ ^3%s ^4] ^3%s^1 : ^4%s", szGroups[ groupid ][ Name ], szName, szMessage )
- else
- ColorChat( 0, "^4[ ^3%s ^4] ^3%s^1 : ^4%s", g_szAdminChat[name[id]], szName, szMessage )
- #if defined LOG
- new auth[ 35 ], ip[ 26 ];
- get_user_authid( id, auth, sizeof auth - 1 );
- get_user_ip( id, ip, sizeof ip - 1, 1 );
- log_to_file( szLogFile, "[%s] %s < %s >< %s > says: %s.", szGroups[ groupid ][ Name ], szName, auth, ip, szMessage );
- #endif
- g_iHudPosition ++;
- g_flLastTsay[ id ] = get_gametime( );
- if( g_iHudPosition > 3 )
- g_iHudPosition = 0;
- return 1;
- }
- return 0;
- }
- stock StartWith( Msg[ ], Msg2[ ] )
- {
- return( equal( Msg, Msg2, strlen( Msg2 ) ) );
- }
- stock GetGroupID( flags )
- {
- for( new i = 0 ; i < sizeof szGroups ; i ++ )
- {
- if( flags & szGroups[ i ][ Flag ] )
- return i;
- }
- return -1;
- }
- stock ColorChat( index, message[], any:... )
- {
- if( index && !is_user_connected( index ) || !index && !get_playersnum( ) )
- return 0;
- static szMessage[ 242 ];
- vformat( szMessage, charsmax( szMessage ), message, 3 );
- static st_msgid;
- if( !st_msgid )
- st_msgid = get_user_msgid( "SayText" );
- if( index )
- {
- message_begin( MSG_ONE_UNRELIABLE, st_msgid, _, index );
- write_byte( index );
- write_string( szMessage );
- message_end( );
- }
- else
- {
- static cc_glb_maxids;
- if( !cc_glb_maxids )
- cc_glb_maxids = get_maxplayers( );
- for( index = 1 ; index <= cc_glb_maxids ; index ++ )
- {
- if( !is_user_connected( index ) )
- continue;
- message_begin( MSG_ONE_UNRELIABLE, st_msgid, _, index );
- write_byte( index );
- write_string( szMessage );
- message_end( );
- }
- }
- return 1;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement