/* ATAC Cerberus ban
*
* Copyright © 2006-2007, Zefir
*
* This file is provided as is (no warranties).
*
* for version 3.3.1
*
*/

#include <amxmodx>
#include <atac>
#pragma dynamic 64

#define PLUGIN "ATAC Cerberus"
#define VERSION "1.0"
#define AUTHOR "Zefir"

new gBanning[ 33 ]
new gCVARTeamKills
new gCVARBanTime

public plugin_init()
{
	register_plugin( PLUGIN, VERSION, AUTHOR )
	new cerberus = get_cvar_pointer( "cerberus_version" ) // Check to see if the server has AMX Bans installed

	if ( !cerberus ) {
		pause( "ade", PLUGIN )
	} else {
		atac_register_addon()
		gCVARTeamKills = get_cvar_pointer( "atac_team_kills" )
		gCVARBanTime = get_cvar_pointer( "atac_ban_time" )
	}
}

public client_putinserver( id )
{
	gBanning[ id ] = 0
}

public atac_punished( killer, const name[], const authid[], bantype )
{
	server_print( "[ATAC] atac_punished ^"%s^" %i", name, bantype )

	if ( !bantype ) // 0 = Kick, DO NOT BAN!
		return PLUGIN_CONTINUE  // Allow ATAC to carry on as normal

	if ( gBanning[ killer ] ) // Check to make sure we are not trying to ban the client already
		return PLUGIN_HANDLED // Supercede ATAC's banning system

	new tk = get_atac_kills( killer )
	new maxtk = get_pcvar_num( gCVARTeamKills )

	if ( tk >= maxtk ) // Let AMX Bans take over
	{
		gBanning[ killer ] = 1

		server_cmd( "amx_ban ^"%s^" %i Max Team Kill Warning %i/%i", name, get_pcvar_num( gCVARBanTime ), tk, maxtk )

		return PLUGIN_HANDLED // Supercede ATAC's banning system
	}
	return PLUGIN_CONTINUE // Allow ATAC to carry on as normal
}
