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

new const nazwa[]   = "ShiBBy [MegaP]";
new const opis[]    = "1/1 z Scouta , 1/5 z Deagle.";
new const bronie    = 1<<CSW_SCOUT | 1<<CSW_M4A1 | 1<<CSW_DEAGLE;
new const zdrowie   = 10;
new const kondycja  = 10;
new const inteligencja = 0;
new const wytrzymalosc = 15;

new bool: ma_klase[33];

public plugin_init()
{
	register_plugin(nazwa, "1.0", "Play");
	
	cod_register_class(nazwa, opis, bronie, zdrowie, kondycja, inteligencja, wytrzymalosc);
	
	RegisterHam(Ham_TakeDamage, "player", "TakeDamage");
}

public cod_class_enabled(id)
{
	if(!(get_user_flags(id) & ADMIN_LEVEL_F))
	{
		ColorChat(id, NORMAL, "^x03[COD:MW3]^x01 Nie masz uprawnien, aby uzywac tej klasy.")
		return COD_STOP;
	}
	ma_klase[id] = true;
	return COD_CONTINUE;
}
public cod_class_disabled(id)	
	ma_klase[id] = false;
	

public TakeDamage(this, idinflictor, idattacker, Float:damage, damagebits)
{
	if(!is_user_connected(idattacker))
		return HAM_IGNORED; 
	
	if(!ma_klase[idattacker])
		return HAM_IGNORED;
	
	if(damagebits & DMG_BULLET)
	{
		new weapon = get_user_weapon(idattacker);
		
		if(weapon == CSW_SCOUT && random_num(1,1) == 1) 
			cod_inflict_damage(idattacker, this, float(get_user_health(this))-damage+1.0, 0.0, idinflictor, damagebits);
			
		if(weapon == CSW_DEAGLE && random_num(1,5) == 1) 
			cod_inflict_damage(idattacker, this, float(get_user_health(this))-damage+1.0, 0.0, idinflictor, damagebits);		
			
	}	
	return HAM_IGNORED;
}

