/* ATAC HudMessages
*
* Copyright © 2006-2007, ATAC Team
*
* This file is provided as is (no warranties).
*
*/

#include <amxmodx>
#include <amxmisc>
#include <atac>

#define PLUGIN "Hud Messages"
#define VERSION "1.0"
#define AUTHOR "ATAC Team"

new gCVARTeamAttacks
new gCVARTeamKills
new gCVARBanTime
new gCVARBanType

new gHudSyncDamage
new gHudSyncKill

new TeamAttacks[ 33 ]
new TeamKills[ 33 ]

public plugin_init()
{
	register_plugin( PLUGIN, VERSION, AUTHOR )
	atac_register_addon()

	gCVARTeamAttacks = get_cvar_pointer( "atac_team_attacks" )
	gCVARTeamKills = get_cvar_pointer( "atac_team_kills" )
	gCVARBanTime = get_cvar_pointer( "atac_ban_time" )
	gCVARBanType = get_cvar_pointer( "atac_ban_type" )
	
	gHudSyncDamage = CreateHudSyncObj()
	gHudSyncKill = CreateHudSyncObj()
}

public atac_team_attack( attacker, victim, damage )
{
	TeamAttacks[ attacker ] = get_atac_attacks( attacker )

	if ( TeamAttacks[ attacker ] < get_pcvar_num( gCVARTeamAttacks ) )
	{
		new name[ 32 ]
		get_user_name( victim, name, 31 )
		new team = get_user_team( attacker )
		set_hudmessage( ( team == 1 ) ? 140 : 0, ( team == 2 ) ? 100 : 0, ( team == 2 ) ? 200 : 0, 0.05, 0.42, 2, 0.1, 4.0, 0.02, 0.02, -1 )
		ShowSyncHudMsg( attacker, gHudSyncDamage, "[ATAC] %L", attacker, "ATAC_TA_WARNING", TeamAttacks[ attacker ], get_pcvar_num( gCVARTeamAttacks ), damage, name )
	}
}

public atac_punished( killer, const name[], const authid[] )
{
	if ( is_user_connected( killer ) )
	{
		new team = get_user_team( killer )
		set_hudmessage( ( team == 1 ) ? 140 : 0, ( team == 2 ) ? 100 : 0, ( team == 2 ) ? 200 : 0, 0.05, 0.50, 2, 0.1, 4.0, 0.02, 0.02, -1 )
	}
	else
		set_hudmessage( 255, 25, 255, 0.05, 0.50, 2, 0.1, 4.0, 0.02, 0.02, -1 )

	new max_tk = get_pcvar_num( gCVARTeamKills )
	TeamKills[ killer ] = get_atac_kills( killer )

	if ( TeamKills[ killer ] >= max_tk )
	{
		new ban = get_pcvar_num( gCVARBanType )
		new ban_time = get_pcvar_num( gCVARBanTime )

		if ( !ban )
			ShowSyncHudMsg( 0, gHudSyncKill, "[ATAC] %L", LANG_PLAYER, "ATAC_TK_KICK", TeamKills[ killer ], max_tk, name )
		else
		{
			if ( ban_time )
				ShowSyncHudMsg( 0, gHudSyncKill, "[ATAC] %L", LANG_PLAYER, "ATAC_TK_BAN_MIN", TeamKills[ killer ], max_tk, name, ban_time )
			else
				ShowSyncHudMsg( 0, gHudSyncKill, "[ATAC] %L", LANG_PLAYER, "ATAC_TK_BAN_PERM", TeamKills[ killer ], max_tk, name )
		}
	}
	else if ( is_user_connected( killer ) )
		ShowSyncHudMsg( killer, gHudSyncKill, "[ATAC] %L", killer, "ATAC_TK_WARNING", TeamKills[ killer ], max_tk )
}
