Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include < amxmodx >
- #define IsValidPlayer(%0) ( 1 <= %0 <= g_iMaxPlayers )
- new g_bConnected[ 33 ] = false;
- new g_iTeam[ 33 ];
- new g_szName[ 33 ][ 32 ];
- new bool: g_bHasPrefix[ 33 ] = false;
- new g_iMessageChat;
- new g_iMaxPlayers;
- public plugin_init( ) {
- register_plugin( "VIP: Chat Prefix for user info", "1.0", "Milutinke (ByM)" );
- register_event( "TeamInfo", "fw_EventTeamInfo", "a" );
- register_clcmd( "say", "fw_ChatPrefix" );
- register_clcmd( "say_team", "fw_ChatPrefixTeam" );
- g_iMessageChat = get_user_msgid( "SayText" );
- g_iMaxPlayers = get_maxplayers( );
- }
- public client_connect( iPlayer ) {
- g_bHasPrefix[ iPlayer ] = false;
- g_bConnected[ iPlayer ] = false;
- g_iTeam[ iPlayer ] = 0;
- }
- public client_putinserver( iPlayer )
- g_bConnected[ iPlayer ] = true;
- public client_authorized( iPlayer ) {
- get_user_name( iPlayer, g_szName[ iPlayer ], charsmax( g_szName[ ] ) );
- new szInfo[ 32 ];
- if( get_user_info( iPlayer, "vip", szInfo, charsmax( szInfo ) ) ) {
- trim( szInfo );
- if( szInfo[ 0 ] == EOS )
- return;
- g_bHasPrefix[ iPlayer ] = bool: equal( szInfo, "1" );
- }
- }
- public client_disconnect( iPlayer ) {
- g_szName[ iPlayer ][ 0 ] = EOS;
- g_bHasPrefix[ iPlayer ] = false;
- g_bConnected[ iPlayer ] = false;
- g_iTeam[ iPlayer ] = 0;
- }
- public client_infochanged( iPlayer ) {
- new szName[ 32 ];
- get_user_name( iPlayer, szName, charsmax( szName ) );
- if( !equal( g_szName[ iPlayer ], szName ) )
- copy( g_szName[ iPlayer ], charsmax( g_szName[ ] ), szName );
- }
- public fw_EventTeamInfo( ) {
- new iPlayer = read_data( 1 );
- if( !g_bConnected[ iPlayer ] )
- return PLUGIN_CONTINUE;
- new szTeam[ 12 ];
- read_data( 2, szTeam, charsmax( szTeam ) );
- switch( szTeam[ 0 ] ) {
- case 'T' : g_iTeam[ iPlayer ] = 1;
- case 'C' : g_iTeam[ iPlayer ] = 2;
- case 'S' : g_iTeam[ iPlayer ] = 3;
- default: g_iTeam[ iPlayer ] = 4;
- }
- return PLUGIN_CONTINUE;
- }
- public fw_ChatPrefix( iPlayer ) {
- if( !g_bConnected[ iPlayer ] || !IsValidPlayer( iPlayer ) )
- return 2;
- static szSaid[ 191 ];
- read_args( szSaid, charsmax( szSaid ) );
- remove_quotes( szSaid );
- return ChatPrefix( iPlayer, szSaid, charsmax( szSaid ), false );
- }
- public fw_ChatPrefixTeam( iPlayer ) {
- if( !g_bConnected[ iPlayer ] || !IsValidPlayer( iPlayer ) )
- return 2;
- static szSaid[ 191 ];
- read_args( szSaid, charsmax( szSaid ) );
- remove_quotes( szSaid );
- return ChatPrefix( iPlayer, szSaid, charsmax( szSaid ), true );
- }
- public ChatPrefix( const iPlayer, szSaid[ ], const iSaidLength, const bTeamChat ) {
- static szMessage[ 191 ], iPlayers;
- if( !szSaid[ 0 ] )
- return 2;
- formatex( szMessage, charsmax( szMessage ), "%s!t%s: !n%s", g_bHasPrefix[ iPlayer ] ? "!g[VIP] " : "", g_szName[ iPlayer ], szSaid );
- replace_all( szMessage, charsmax( szMessage ), "%", "" );
- replace_all( szMessage, charsmax( szMessage ), "!n", "^x01" );
- replace_all( szMessage, charsmax( szMessage ), "!r", "^x02" );
- replace_all( szMessage, charsmax( szMessage ), "!g", "^x04" );
- replace_all( szMessage, charsmax( szMessage ), "!t", "^x03" );
- trim( szMessage );
- for( iPlayers = 1; iPlayers <= g_iMaxPlayers; iPlayers ++ ) {
- if( !g_bConnected[ iPlayer ] )
- continue;
- if( bTeamChat ) {
- if( get_user_team( iPlayer ) != get_user_team( iPlayers ) )
- continue;
- }
- message_begin( MSG_ONE, g_iMessageChat, { 0, 0, 0 }, iPlayers );
- write_byte( iPlayer );
- write_string( szMessage );
- message_end( );
- }
- return 2;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement