#include <amxmodx>
#include <codmod>
#include <hamsandwich>
#include <fakemeta_util>

new const perk_name[] = "Lodowe strzaly";
new const perk_desc[] = "Masz 1/12 szansy na zamrozenie przeciwnika. Zamrozenie trwa 5 sec.";
new bool:ma_perk[32]
new bool:zamrozenie[32]


public plugin_init() 
{
	register_plugin(perk_name, "1.0", "Czyzyk");
	cod_register_perk(perk_name, perk_desc);
	RegisterHam(Ham_TakeDamage, "player", "TakeDamage", 1)
}
public cod_perk_enabled(id)
{
	ma_perk[id] = true
}

public cod_perk_disabled(id)
{
	ma_perk[id] = false
}

public TakeDamage(this, idinflictor, idattacker, Float:damage, damagebits)
{
	new liczba = random_num(1, 12)
	
	if(!is_user_connected(idattacker))
		return HAM_IGNORED;

	if(!ma_perk[idattacker])
		return HAM_IGNORED;
		
	if(ma_perk[idattacker] && damage>0 && !zamrozenie[this] && liczba==12){
		fm_set_rendering(this, kRenderFxGlowShell, 0,0,255, kRenderGlow, 16)
		zamrozenie[this] = true
		set_pev(this, pev_flags, FL_FROZEN)
		set_task(5.0, "Odmroz", this)
	}
	if(zamrozenie[this])
		return HAM_SUPERCEDE
		
	return HAM_IGNORED
}

public Odmroz(id)
{
	set_pev(id, pev_flags, FL_CLIENT)
	fm_set_rendering(id, kRenderFxGlowShell, 0,0,0, kRenderGlow, 0)
	zamrozenie[id] = false
}
		



