#include <amxmodx>
#include <dhudmessage>
#include <csx>

#define	MAX_SIZE_ID	33

new gHideWeapon, celownik_schowany[33]
new is_friend[MAX_SIZE_ID];
new hud_d;

public plugin_init() 
{
	register_plugin("Celownik (X)", "1.0", "Play")
	register_event("Damage", "client_damage", "b", "2!0", "3=0", "4!0");
	register_event("StatusValue", "event_statusvalue_team", "be", "1=1");
	
	hud_d = register_cvar("hud_design", "2") //  0 - Bez (X)   |   1 - Normalny  |   2 - DHUD
	
	gHideWeapon = get_user_msgid("HideWeapon")
}
public client_damage(attacker,victim,damage,wpn,hitplace,TA)
{	
	if(TA)
		return PLUGIN_CONTINUE
  
	switch(get_pcvar_num(hud_d))
	{
		case(1):
		{			
			set_hudmessage(170, 255, 255, -1.0, -1.0, 0, 6.0, 1.2)
			show_hudmessage(attacker,"X");	
		}
		case(2):
		{		
			set_dhudmessage(170, 255, 255, -1.0, -1.0, 0, 0.1, 0.1);
			show_dhudmessage(attacker,"X");
		}
	}
	
	if(celownik_schowany[attacker]==0)
	{
		message_begin(MSG_ONE, gHideWeapon, _, attacker)
		write_byte((1<<6))
		message_end()
		celownik_schowany[attacker]=1
		
	}
	if(!task_exists(attacker))
	{
		set_task(1.2,"pokaz_celownik",attacker)
	}
	else
	{
		change_task(attacker,1.2)
	}
	return PLUGIN_CONTINUE;
}
public pokaz_celownik(id)
{
	message_begin(MSG_ONE, gHideWeapon, _, id)
	write_byte(0)
	message_end()
	celownik_schowany[id]=0
}
public event_statusvalue_team(id)
{
	if(!is_user_bot(id) && is_user_connected(id))
	{
		is_friend[id] = read_data(2);
	}
}

