/* Plugin generated by AMXX-Studio */

#include <amxmodx>
#include <engine>
#include <codmod>

new const nazwa[] = "Rozblysk";
new const opis[] = "Uzyj, aby oslepic wrogow w promieniu 250(+inteligencja)";

new bool:uzyl[33];

new sprite_white;
     
new g_msg_screenfade;

public plugin_init()
 {
	register_plugin(nazwa, "1.0", "QTM_Peyote");
	
	cod_register_perk(nazwa, opis);
	
	register_event("ResetHUD", "ResetHUD", "abe");
	g_msg_screenfade = get_user_msgid("ScreenFade");
}

public plugin_precache()
	sprite_white = precache_model("sprites/white.spr");

public cod_perk_enabled(id)
	uzyl[id] = false;
	
public cod_perk_used(id)
{	
	if(uzyl[id] || !is_user_alive(id))
		return PLUGIN_CONTINUE;

	uzyl[id] = true;
	
	new iOrigin[3];
	get_user_origin(id, iOrigin);
	
	message_begin( MSG_BROADCAST, SVC_TEMPENTITY, iOrigin );
	write_byte( TE_BEAMCYLINDER );
	write_coord( iOrigin[0] );
	write_coord( iOrigin[1] );
	write_coord( iOrigin[2] );
	write_coord( iOrigin[0] );
	write_coord( iOrigin[1] + 250 );
	write_coord( iOrigin[2] + 250 );
	write_short( sprite_white );
	write_byte( 0 ); 
	write_byte( 0 ); 
	write_byte( 10 ); 
	write_byte( 120 ); 
	write_byte( 255 ); 
	write_byte( 0 ); 
	write_byte( 255 );
	write_byte( 0 ); 
	write_byte( 128 ); 
	write_byte( 0 ); 
	message_end();
	
	new entlist[33];
	new numfound = find_sphere_class(id, "player", 250.0+cod_get_user_intelligence(id) , entlist, 32);
		
	for (new i=0; i < numfound; i++)
	{		
		new pid = entlist[i];
		
		if (is_user_alive(pid) && get_user_team(id) != get_user_team(pid))
			Display_Fade(pid, 1<<14, 1<<14 ,1<<16, 0, 255, 0, 230);
	}
	
	return PLUGIN_CONTINUE;
}

public ResetHUD(id)
	uzyl[id] = false;

stock Display_Fade(id,duration,holdtime,fadetype,red,green,blue,alpha)
{
	message_begin( MSG_ONE, g_msg_screenfade,{0,0,0},id );
	write_short( duration );
	write_short( holdtime );	
	write_short( fadetype );	
	write_byte ( red );		
	write_byte ( green );		
	write_byte ( blue );	
	write_byte ( alpha );	
	message_end();
}
