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


new const nazwa[] = "Dzika kuna";
new const opis[] = "Auto BH, zapierdala jak strus, 2 skoki";
new const bronie = 1<<CSW_SCOUT;
new const zdrowie = 0;
new const kondycja = 50;
new const inteligencja = 0;
new const wytrzymalosc = 0;

new bool: ma_klase[33];
new skoki[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");
	register_forward(FM_CmdStart, "fwCmdStart_MultiJump");
}
public cod_class_enabled(id)
	ma_klase[id] = true;
	
public cod_class_disabled(id)
	ma_klase[id] = false;
	
public fwCmdStart_MultiJump(id, uc_handle)
{
	if(!is_user_alive(id) || !ma_klase[id])
		return FMRES_IGNORED;

	new flags = pev(id, pev_flags);

	if((get_uc(uc_handle, UC_Buttons) & IN_JUMP) && !(flags & FL_ONGROUND) && !(pev(id, pev_oldbuttons) & IN_JUMP) && skoki[id])
	{
		skoki[id]--;
		new Float:velocity[3];
		pev(id, pev_velocity,velocity);
		velocity[2] = random_float(265.0,285.0);
		set_pev(id, pev_velocity,velocity);
	}
	else if(flags & FL_ONGROUND)
		skoki[id] = 1;

	return FMRES_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;
}