/* AMX Mod X
*   Anti TeamAttacker Plugin
*   
*/

#include <amxmodx>
#include <fun>

new PLUGIN[]="Anti TeamAttacker"
new AUTHOR[]="JohnJ"
new VERSION[]="1.00"

new FFCAN[]="amx_friendlyfire"

public plugin_init()
{
	register_plugin(PLUGIN, VERSION, AUTHOR)
	register_cvar(FFCAN, "0")
}

public client_damage(attacker,victim,damage,wpnindex,hitplace,TA)
{
	new friendlyfirecan = get_cvar_float(FFCAN)
	new oneteam=get_user_team(attacker)==get_user_team(victim)

	if ((friendlyfirecan==0) && (oneteam) && (attacker!=victim))
	{
	 new hpa=get_user_health(attacker)
	 new hpv=get_user_health(victim)
	 set_user_health(attacker,hpa-damage)
	 set_user_health(victim,hpv+damage)
	}

	return PLUGIN_CONTINUE
}