#include <amxmodx>
#include <fakemeta>

#define m_flNextAttack 83


new HUD;
new pCvarCzas, CzasBlokady, g_msg_screenfade;

public plugin_init()
{
	register_plugin("Blokada HE", "9", "Play");
	register_logevent("PoczatekRundy", 2, "1=Round_Start"); 
	register_event("HLTV", "NowaRunda", "a", "1=0", "2=0");
	register_forward(FM_PlayerPreThink, "client_PreThink");
	
	pCvarCzas = register_cvar("cod_czasblokady", "10");
	
	
	HUD = CreateHudSyncObj();
	g_msg_screenfade = get_user_msgid("ScreenFade");
	
}

public client_PreThink(id)
{
	if(task_exists(-44) && get_user_weapon(id) == CSW_HEGRENADE)
	{
		set_hudmessage(60, 200, 25, -1.0, 0.25, 0, 1.0, 2.0, 0.1, 0.2, 2);
		ShowSyncHudMsg(id, HUD, "HE jest zablokowane przez %i sekund.^nNie lam zasad", CzasBlokady);
		Display_Fade(id, 1<<9, 1<<3, 1<<3, 255, 0, 0, 200)
		set_pdata_float(id, m_flNextAttack, 0.1 , 5);
	}
}
public NowaRunda()
{
	set_task(15.0, "info");
}
public PoczatekRundy()
{
	set_task(1.0, "Odblokuj", -44, _, _, "a", CzasBlokady = get_pcvar_num(pCvarCzas));
}

public Odblokuj()
{
	CzasBlokady--;
}
public info()
{
	set_hudmessage(60, 200, 25, -1.0, 0.25, 0, 1.0, 2.0, 0.1, 0.2, 2);
	ShowSyncHudMsg(0, HUD, "HE zostal odblokowany!");
}
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 );	// Duration of fadeout
	write_short( holdtime );	// Hold time of color
	write_short( fadetype );	// Fade type
	write_byte ( red );		// Red
	write_byte ( green );		// Green
	write_byte ( blue );		// Blue
	write_byte ( alpha );	// Alpha
	message_end();
}
