This will ban the whole team ( since it's a 1v1, only the player on the losing team thus ). should work fine
PHP Code:
#include < amxmodx >
#if AMXX_VERSION_NUM < 183
#define client_disconnected client_disconnect
#endif
new pRounds;
new pPunish;
enum
{
TEAM_T = 1,
TEAM_CT = 2
}
new iPunish[ 2 ];
public plugin_init()
{
register_plugin( "Ban if lose", "1.0", "DusT" );
pRounds = register_cvar( "tt_punish_after", "3" ); // rounds
pPunish = register_cvar( "tt_punish_type", "amx_ban [user] 5 You Lost" ); // use [user] to identify the player
register_message( get_user_msgid( "TextMsg" ), "MsgTextMsg" );
}
public MsgTextMsg( const MsgId, const MsgDest, const MsgEntity )
{
static const TerroristMsg[] = "#Terrorists_Win";
static const CTMsg [] = "#CTs_Win";
static Message[ sizeof TerroristMsg + 1 ];
get_msg_arg_string( 2, Message, charsmax( Message ) );
if( equal( Message, TerroristMsg ) )
{
iPunish[ TEAM_CT - 1 ]++;
CheckPunish( TEAM_CT );
}
else if( equal( Message, CTMsg ) )
{
iPunish[ TEAM_T - 1 ]++;
CheckPunish( TEAM_T );
}
}
public CheckPunish( team )
{
static const szTeams[][] = { "", "TERRORIST", "CT", "" };
if( iPunish[ team - 1 ] >= get_pcvar_num( pRounds ) )
{
new players[ 32 ], num;
get_players( players, num, "e", szTeams[ team ] );
new str[ 128 ], userid[ 10 ];
get_pcvar_string( pPunish, str, charsmax( str ) );
for( new i; i < num; i++ )
{
//replace_string( str, charsmax( str ), "[user]", fmt( "#%d", get_user_userid( players[ i ] ) ) );
formatex( userid, charsmax( userid ), "#%d", get_user_userid( players[ i ] ) );
replace_all( str, charsmax( str ), "[user]", userid );
server_cmd( str );
}
iPunish[ 0 ] = 0;
iPunish[ 1 ] = 0;
}
}
public client_disconnected( id )
{
if( TEAM_T <= get_user_team( id ) <= TEAM_CT )
{
iPunish[ 0 ] = 0;
iPunish[ 1 ] = 0;
}
}