#include <amxmodx>
#include <csx>

#define PLUGIN "Death HitPlace Details"
#define VERSION "1.0"
#define AUTHOR "Alka"

new
head_hit[32],
chest_hit[32],
leftarm_hit[32],
rightarm_hit[32],
leftleg_hit[32],
rightleg_hit[32],
stomach_hit[32],
total_hits[32];

new toggle_plugin;

public plugin_init() {
	
	register_plugin(PLUGIN, VERSION, AUTHOR)
	
	register_logevent("round_start", 2, "1=Round_Start")
	
	toggle_plugin = register_cvar("amx_showhitplace","1")
}

public client_damage(attacker,victim,damage,weapon,hitplace,ta)
{
	if(!get_pcvar_num(toggle_plugin))
		return 1;
	
	if(hitplace == HIT_HEAD || hitplace == HIT_CHEST || hitplace == HIT_STOMACH || hitplace == HIT_LEFTARM || hitplace == HIT_RIGHTARM || hitplace == HIT_LEFTLEG || hitplace == HIT_RIGHTLEG)
		total_hits[victim] ++
	
	if(hitplace == HIT_HEAD)
		head_hit[victim] ++
	
	else if(hitplace == HIT_CHEST)
		chest_hit[victim] ++
	
	else if(hitplace == HIT_STOMACH)
		stomach_hit[victim] ++
	
	else if(hitplace == HIT_LEFTARM)
		leftarm_hit[victim] ++
	
	else if(hitplace == HIT_RIGHTARM)
		rightarm_hit[victim] ++
	
	else if(hitplace == HIT_LEFTLEG)
		leftleg_hit[victim] ++
	
	else if(hitplace == HIT_RIGHTLEG)
		rightleg_hit[victim] ++
	
	return 0;
}

public client_death(killer,victim,weapon,hitplace,tk)
{
	if(!get_pcvar_num(toggle_plugin))
		return 1;
	
	set_hudmessage(0, 255, 255, -1.0, -0.49, 0, 2.0, 5.0, 0.1, 0.1, -1)
	show_hudmessage(victim, "(%d)^n--%d--[%d]--%d--^n[%d]^n%d %d^n_/  \_",head_hit[victim],leftarm_hit[victim],chest_hit[victim],rightarm_hit[victim],stomach_hit[victim],leftleg_hit[victim],rightleg_hit[victim])
	
	set_hudmessage(255, 25, 0, 0.45, 0.51, 0, 2.0, 5.0, 0.1, 0.1, -1)
	show_hudmessage(victim,"Total Hits: %d",total_hits[victim])
	
	return 1;
}

public round_start()
{
	if(!get_pcvar_num(toggle_plugin))
		return 1;
	
	new players[32], num
	get_players(players, num)
	
	new player
	for(new i = 0; i < num; i++)
	{
		player = players[i]
		
		head_hit[player] = 0
		chest_hit[player] = 0
		stomach_hit[player] = 0
		leftarm_hit[player] = 0
		rightarm_hit[player] = 0
		leftleg_hit[player] = 0
		rightleg_hit[player] = 0
		
		total_hits[player] = 0
	}
	return 1;
}
