/* Plugin generated by AMXX-Studio */

#include <amxmodx>
#include <codmod>

new const nazwa[] = "Telegrafista";
new const opis[] = "Widzi wrogow na radarze";
new const bronie = 1<<CSW_AK47 | 1<<CSW_DEAGLE;
new const zdrowie = 6;
new const kondycja = 10;
new const inteligencja = 10;
new const wytrzymalosc = 15;

new g_msgHostageAdd, g_msgHostageDel;

new bool:ma_klase[33];

public plugin_init() 
{	
	register_plugin(nazwa, "1.0", "Play");
	
	g_msgHostageAdd = get_user_msgid("HostagePos");
	g_msgHostageDel = get_user_msgid("HostageK");
	
	cod_register_class(nazwa, opis, bronie, zdrowie, kondycja, inteligencja, wytrzymalosc);
	
	set_task (2.0,"radar_scan",_,_,_,"b");
	
}

public cod_class_enabled(id)
{
	ma_klase[id] = true;
}
public cod_class_disabled(id)
{
	ma_klase[id] = false;
}
public radar_scan(id)
{
	new PlayerCoords[3];
	
	for (new id=1; id<=32; id++)
	{
		if((!is_user_alive(id))||(!ma_klase[id])) continue;
		
		for (new i=1;i<=32;i++)
		{       
			if(!is_user_alive(i) || get_user_team(i) == get_user_team(id)) continue;
			
			get_user_origin(i, PlayerCoords)
			
			message_begin(MSG_ONE_UNRELIABLE, g_msgHostageAdd, {0,0,0}, id)
			write_byte(id)
			write_byte(i)                                 
			write_coord(PlayerCoords[0])
			write_coord(PlayerCoords[1])
			write_coord(PlayerCoords[2])
			message_end()
			
			message_begin(MSG_ONE_UNRELIABLE, g_msgHostageDel, {0,0,0}, id)
			write_byte(i)
			message_end()
		}
	}
}
