Plugin-uri[Plugin] amx_tagchat (Player Tag)

Moderatori: Moderators, Founder

Mesaj

Avatar utilizator
CEO
Posts
3802
Descriere: Acest plugin ofera posibilitatea de a adauga TAG pentru anumiti playeri de pe server (folosind numele, ipul sau steamidul jucatorului respectiv)

Exemplu "[Owner] Nume-Jucator: textul afisat in chat" (dupa cum se poate vedea si in imaginea de mai jos)

Este o alternativa creata dupa pluginul `Allchat` al lui "Ian Cammarata".

Descarcare: -

Credite::
1. Ian Cammarata
2. Askhanar

SMA:

Cod: Selectaţi tot

#include < amxmodx >
#include < amxmisc >
#include < fakemeta >

static const PLUGIN[ ] = "AllChat + Tag";
static const VERSION[ ] = "v1.2b";

new szFile[ 128 ];

new PlayerTag[ 33 ][ 32 ];
new bool:PlayerHasTag[ 33 ];

//cvar pointers
new tc_allchat, tc_alltalk, tc_hidestat, tc_teamchat;

//vars to check if message has already been duplicated
new alv_sndr, alv_szSTRM[26], alv_str4[101]
new msg[200];

public plugin_init( )
{
	register_plugin( PLUGIN, VERSION, "Ian Cammarata" );
	register_concmd( "amx_reloadtags", "Action_ReloadTags", -1, "" );
	register_cvar("allchat_version",VERSION,FCVAR_SERVER)	

	register_forward( FM_ClientUserInfoChanged, "fwClientUserInfoChanged" );
	
	tc_allchat = register_cvar( "sv_allchat", "2" )
	tc_hidestat = register_cvar( "tc_hidestatus", "0" )
	tc_teamchat = register_cvar( "tc_teamchat", "1" )
	
	tc_alltalk = get_cvar_pointer( "sv_alltalk" )
	
	register_message( get_user_msgid("SayText"), "col_changer" )
}

public plugin_precache( ) 
{
	get_configsdir( szFile, sizeof ( szFile ) -1 );
	formatex( szFile, sizeof ( szFile ) -1, "%s/amx_tags.ini", szFile );
	
	if( !file_exists( szFile ) ) 
	{
		write_file( szFile, ";^"Name^" ^"IP^" ^"SteamID^" ^"Player Tag^" ", -1 );
		write_file( szFile, "; TAGURILE se dau sau pe NUME, sau pe IP, sau pe STEAMID !", -1 );
		write_file( szFile, "; A nu se da tag pe nume, ip si/sau steamid in acelasi timp !", -1 );
	}
}

public col_changer( msg_id, msg_dest, rcvr )
{
	new szSTRM[26]
	get_msg_arg_string( 2, szSTRM, 25 )
	if( equal( szSTRM, "#Cstrike_Chat", 13 ) )
	{
		new str3[22]
		get_msg_arg_string( 3, str3, 21 )
		
		if( !strlen( str3 ) )
		{
			new str4[101]
			get_msg_arg_string( 4, str4, 100 )
			new sndr = get_msg_arg_int( 1 )
			
			new bool:is_team_msg = !bool:equal( szSTRM, "#Cstrike_Chat_All", 17 )
			
			new sndr_team = get_user_team( sndr )
			new bool:is_sndr_spec = !bool:( 0 < sndr_team < 3 )
			
			new bool:same_as_last = bool:( alv_sndr == sndr && equal( alv_szSTRM, szSTRM ) && equal( alv_str4, str4) )
			
			if( !same_as_last )
			{	//Duplicate message once
				new allchat = clamp( get_pcvar_num( tc_allchat ), 0, 2 )
				if( allchat == 2 || ( allchat == 1 && clamp( get_pcvar_num( tc_alltalk ), 0, 1 ) == 1 ) )
				{
					if( !( is_team_msg && ( is_sndr_spec || is_team_msg && get_pcvar_num( tc_teamchat ) == 0 ) ) )
					{//Don't duplicate if it's a spectator team message
						new flags[5], team[10]
						if( is_user_alive( sndr ) ) flags = "bch"
						else flags = "ach"
						
						if( is_team_msg )
						{
							add( flags[strlen( flags )], 4, "e" )
							if( sndr_team == 1 ) team = "TERRORIST"
							else team = "CT"
						}
						
						new players[32], num
						get_players( players, num, flags, team )

						buildmsg( sndr, is_sndr_spec, is_team_msg, sndr_team, str4 )

						for( new i=0; i < num; i++ )
						{
							message_begin( MSG_ONE, get_user_msgid( "SayText" ), _, players )
							write_byte( sndr )
							write_string( msg )
							message_end()
						}
						
					}
	
					alv_sndr = sndr
					alv_szSTRM = szSTRM
					alv_str4 = str4
					if( task_exists( 411 ) ) remove_task( 411 )
					set_task( 0.1, "task_clear_antiloop_vars", 411 )
				}
			}
			
			if( !same_as_last ) 
			buildmsg( sndr, is_sndr_spec, is_team_msg, sndr_team, str4 )

			set_msg_arg_string( 2, msg )
			set_msg_arg_string( 4, "" )
		}
	}
	return PLUGIN_CONTINUE
}

public buildmsg( sndr, is_sndr_spec, is_team_msg, sndr_team, str4[ ] )
{
	new sndr_name[33]
	get_user_name( sndr, sndr_name, 32 )
	
	new prefix[30] = "^x01"
	if( get_pcvar_num( tc_hidestat ) == 0 )
	{
		if( is_sndr_spec ) prefix = "^x01*SPEC* "
		else if( !is_user_alive( sndr ) ) prefix = "^x01*DEAD* "
	}
	
	if( is_team_msg )
	{
		if( is_sndr_spec ) prefix = "^x01(Spectator) "
		else if( sndr_team == 1 ) add( prefix[strlen(prefix)-1], 29, "(Terrorist) " )
		else if( sndr_team == 2 ) add( prefix[strlen(prefix)-1], 29, "(Counter-Terrorist) " )
	}
	
	format( msg, 199, "^x01%s^x04%s ^x03%s: ^x01%s", strlen( prefix ) > 1 ? prefix : "", PlayerHasTag[sndr] ? PlayerTag[sndr] : "", sndr_name, str4 )
	return PLUGIN_HANDLED
}

public task_clear_antiloop_vars( )
{
	alv_sndr = 0
	alv_szSTRM = ""
	alv_str4 = ""
	return PLUGIN_HANDLED
}

public client_putinserver( id )
{
	if( is_user_bot( id ) || is_user_hltv( id ) ){
		return PLUGIN_CONTINUE; 
	}

	Action_TagLoader( id );
	return PLUGIN_HANDLED;
}

public fwClientUserInfoChanged( id, buffer )
{
	if ( !is_user_connected( id ) )
		return FMRES_IGNORED;
	
	static newname[ 32 ];
	static name[ 32 ];
	
	get_user_name( id, name, sizeof ( name ) -1 );
	engfunc( EngFunc_InfoKeyValue, buffer, "name", newname, sizeof ( newname ) -1 );
	
	if ( equal( newname, name ) )
		return FMRES_IGNORED;

	set_task( 0.1, "Action_TagLoader", id );
	
	return FMRES_SUPERCEDE;
}

public Action_ReloadTags( id )
{
	if( !( get_user_flags( id ) & ADMIN_RCON ) )
	{
		client_cmd( id, "echo Nu ai acces la aceasta comanda !");
		return 1;
	}
	
	new iPlayers[ 32 ];
	new iPlayersNum;

	get_players( iPlayers, iPlayersNum, "c" );		
	for( new i = 0 ; i < iPlayersNum ; i++ )
	{
		PlayerHasTag[ iPlayers[ i ] ] = false;
		Action_TagLoader( iPlayers[ i ] );
	}
	
	client_cmd( id, "echo Tag-urile au fost incarcate cu succes !");
	return 1;
}

public Action_TagLoader( id )
{
	PlayerHasTag[ id ] = false;
	
	if( !file_exists( szFile ) ) 
	{
		write_file( szFile, ";^"Name^" ^"IP^" ^"SteamID^" ^"Player Tag^" ", -1 );
		write_file( szFile, "; TAGURILE se dau sau pe NUME, sau pe IP, sau pe STEAMID !", -1 );
		write_file( szFile, "; A nu se da tag pe nume, ip si/sau steamid in acelasi timp !", -1 );
	}
	
	new file = fopen( szFile, "rt" );
	
	if( !file ) return 0;
	
	new data[ 512 ], buffer[ 4 ][ 32 ] ;
	
	while( !feof( file ) ) 
	{
		fgets( file, data, sizeof ( data ) -1 );
		
		if( !data[ 0 ] || data[ 0 ] == ';' || ( data[ 0 ] == '/' && data[ 1 ] == '/' ) ) 
			continue;
		
		parse(data,\
		buffer[ 0 ], sizeof ( buffer[ ] ) - 1,\
		buffer[ 1 ], sizeof ( buffer[ ] ) - 1,\
		buffer[ 2 ], sizeof ( buffer[ ] ) - 1,\
		buffer[ 3 ], sizeof ( buffer[ ] ) - 1
		);
		
		new fName[ 32 ], ip[32], szAuthID[32];
		get_user_name( id, fName, sizeof ( fName ) -1 );
		get_user_ip( id, ip, sizeof ( ip ) -1 );
   		get_user_authid(id, szAuthID, sizeof ( szAuthID ) -1);
		if( equal( fName, buffer[ 0 ] ) || equal( ip, buffer[ 1 ] ) || equal( szAuthID, buffer[ 2 ] ) )
		{
			PlayerHasTag[ id ] = true;
			copy( PlayerTag[ id ], sizeof ( PlayerTag[ ] ) -1, buffer[ 3 ] );
			break;
		}
	}
	
	return 0;
}


Nume: amx_tagchat
Versiune: 1.2b
Link oficial: -

Instalare:
1. Fisierul amx_tagchat.sma il puneti in addons/amxmodx/scripting
2. Fisierul amx_tagchat.amxx il puneti in addons/amxmodx/plugins
3. Fisierul amx_tags.ini il puneti in addons/amxmodx/configs
4. Intrati in fisierul addons/amxmodx/configs/plugins.ini si adaugati la urma:

Cod: Selectaţi tot

amx_tagchat.amxx
Cvar-uri (se adauga in fisierul amxmodx\configs\amxx.cfg):

Cod: Selectaţi tot

sv_allchat 2
1 - Dependent on sv_alltalk
2 - Always active
0 - Disabled
Default: 2

tc_hidestatus 0
0 = Show dead/spec status.
1 = Hide status.
Default: 0

tc_teamchat 1
0 = Dead and living can't team chat.
1 = Dead and living can team chat.
Default: 1
Comenzi administrative (se tasteaza in consola si trebuie sa fiti administrator):

Cod: Selectaţi tot

amx_reloadtags - pentru a putea da reload la taguri fara a schimba harta v
Comenzi publice (se tasteaza in joc prin apasarea tastei Y): -

Module necesare (se sterge ; din fata modulului de mai jos; acestea le gasiti in fisierul amxmodx\configs\modules.ini):

Cod: Selectaţi tot

- Fakemeta
Imagini:


Observatii:
- Am scos admin colors deoarece mi se parea irelevant.
- Inainte de instalarea acestui plugin se recomanda a se dezactiva pluginurile de genul: ghostchat.amxx / allchat.amxx / admin_chat_colors.amxx / admin_chat_ranks.amxx etc.
========================
CONTACT : diliulro@yahoo.com
========================
Scrie răspuns