#include <amxmodx>
#include <codmod>

new const nazwa[] = "Radar";
new const opis[] = "Na radarze widzisz wszystkich wrogow";


new g_msgHostageAdd, g_msgHostageDel;
new const sound_radar[] = "radar.wav"

new bool:ma_perk[33];


public plugin_init() {
	register_plugin(nazwa, "1.0", "Play");
	
	g_msgHostageAdd = get_user_msgid("HostagePos");
	g_msgHostageDel = get_user_msgid("HostageK");
	
	cod_register_perk(nazwa, opis)
	
	set_task (2.0,"radar_scan",_,_,_,"b");
}

public cod_perk_enabled(id)
	ma_perk[id] = true;
	
public cod_perk_disabled(id)
	ma_perk[id] = false;

public plugin_precache()
	precache_sound(sound_radar)

public radar_scan(id)
{
	new PlayerCoords[3];
                
	for (new id=1; id<=32; id++)
	{
		if((!is_user_alive(id))||(!ma_perk[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()
		}
		emit_sound(id, CHAN_ITEM, sound_radar, 1.0, ATTN_NORM, 0, PITCH_NORM);
	}
}
/* AMXX-Studio Notes - DO NOT MODIFY BELOW HERE
*{\\ rtf1\\ ansi\\ ansicpg1250\\ deff0\\ deflang1045{\\ fonttbl{\\ f0\\ fnil Tahoma;}}\n\\ viewkind4\\ uc1\\ pard\\ f0\\ fs16 \n\\ par }
*/
