/* Plugin generated by AMXX-Studio */

#include <amxmodx>
#include <amxmisc>
#include <codmod>
#include <engine>
#include <hamsandwich>
 
#define DMG_BULLET (1<<1)


new const perk_name[] = "Moc Deagla";
new const perk_desc[] = "Dostajesz deagle + 20 dmg z niego i 40/255 niewidzialnosci";

new bool:ma_perk[33];

public plugin_init() 
{
	register_plugin(perk_name, "1.0", "Play");
	
	cod_register_perk(perk_name, perk_desc);
	
	RegisterHam(Ham_TakeDamage, "player", "TakeDamage");
}
public cod_perk_enabled(id)
{
	ma_perk[id] = true;
	cod_give_weapon(id, CSW_DEAGLE);
	set_rendering(id,kRenderFxNone, 0, 0, 0, kRenderTransAlpha, 40);
}

public cod_perk_disabled(id)
{
	cod_take_weapon(id, CSW_DEAGLE)
	set_rendering(id,kRenderFxNone, 0, 0, 0, kRenderTransAlpha, 255);	
	ma_perk[id] = false;
}

public TakeDamage(this, idinflictor, idattacker, Float:damage, damagebits)
{
	if(!is_user_connected(idattacker))
		return HAM_IGNORED;
	
	if(!ma_perk[idattacker])
		return HAM_IGNORED;
	
	if(damagebits & DMG_BULLET)
	{
		new weapon = get_user_weapon(idattacker);
			
		if(weapon == CSW_DEAGLE)
			cod_inflict_damage(idattacker, this, 20.0, 0.0, idinflictor, damagebits);
	}
	
	return HAM_IGNORED;
}
