#include <amxmodx>
#include <engine>
#include <codmod>

new const perk_name[] = "AutoBH";
new const perk_desc[] = "Dostajesz Auto BH (Trzymaj spacje)";

#define	FL_WATERJUMP	(1<<11)	// popping out of the water
#define	FL_ONGROUND	(1<<9)	// not moving on the ground

new bool:ma_perk[33]

public plugin_init() 
{
	register_plugin(perk_name, "1.0", "Play");
	cod_register_perk(perk_name, perk_desc);
}

public cod_perk_enabled(id)
{
	if(cod_get_user_class(id) == cod_get_classid("Talib"))
		return COD_STOP;
		
	ma_perk[id]=true;
	return PLUGIN_CONTINUE;
}
public cod_perk_disabled(id)
{
	ma_perk[id]=false
}

public client_PreThink(id)
{
	if(!ma_perk[id])
		return PLUGIN_CONTINUE
	entity_set_float(id, EV_FL_fuser2, 0.0)
	if(!ma_perk[id])
		return PLUGIN_CONTINUE
	if (entity_get_int(id, EV_INT_button) & 2) {	
		new flags = entity_get_int(id, EV_INT_flags)
		
		if (flags & FL_WATERJUMP)
			return PLUGIN_CONTINUE
		if ( entity_get_int(id, EV_INT_waterlevel) >= 2 )
			return PLUGIN_CONTINUE
		if ( !(flags & FL_ONGROUND) )
			return PLUGIN_CONTINUE
		
		new Float:velocity[3]
		entity_get_vector(id, EV_VEC_velocity, velocity)
		velocity[2] += 250.0
		entity_set_vector(id, EV_VEC_velocity, velocity)
		
		entity_set_int(id, EV_INT_gaitsequence, 6)
		
	}
	return PLUGIN_CONTINUE
}


