#include <amxmodx>
#include <amxmisc>
#include <codmod>
#include <hamsandwich>
#include <fakemeta>


#define DMG_BULLET (1<<1)
        
new const nazwa[]   = "Talib";
new const opis[]    = "1/6 z deagle, AutoBH";
new const bronie    = 1<<CSW_DEAGLE;
new const zdrowie   = 15;
new const kondycja  = 15;
new const inteligencja = 10;
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);

	register_forward(FM_PlayerPreThink, "fwPrethink_AutoBH");

	RegisterHam(Ham_TakeDamage, "player", "TakeDamage");
	
}

public cod_class_enabled(id)
{
	ma_klase[id] = true;

}
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(get_user_weapon(idattacker) == CSW_DEAGLE && !random(6) && damagebits & DMG_BULLET)
		cod_inflict_damage(idattacker, this, float(get_user_health(this))-damage+1.0, 0.0, idinflictor, damagebits);


	return HAM_IGNORED;
}
public fwPrethink_AutoBH(id)
{
	if(!ma_klase[id])
		return PLUGIN_CONTINUE

	if (pev(id, pev_button) & IN_JUMP) {
		new flags = pev(id, pev_flags)

		if (flags & FL_WATERJUMP)
			return FMRES_IGNORED;
		if ( pev(id, pev_waterlevel) >= 2 )
			return FMRES_IGNORED;
		if ( !(flags & FL_ONGROUND) )
			return FMRES_IGNORED;

		new Float:velocity[3];
		pev(id, pev_velocity, velocity);
		velocity[2] += 250.0;
		set_pev(id, pev_velocity, velocity);

		set_pev(id, pev_gaitsequence, 6);

	}
	return FMRES_IGNORED;
}