/* Plugin generated by AMXX-Studio */

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

#define PLUGIN "Czolganie | Dla klasy [CoD Nowy]"
#define VERSION "1.0"
#define AUTHOR "Sn!ff3r | Edit by d0n tHe Pr0oo"

new bool:moze[33]
new bool:ma_klase[33];

new const nazwa[] = "Cichy Zabojca";
new const opis[] = "Moze sie czolgac";
new const bronie = 1<<CSW_M4A1;
new const zdrowie = 50;
new const kondycja = 45;
new const inteligencja = 0;
new const wytrzymalosc = 20;

public plugin_init() 
{
	register_plugin(PLUGIN, VERSION, AUTHOR)

	cod_register_class(nazwa, opis, bronie, zdrowie, kondycja, inteligencja, wytrzymalosc);

	register_event("HLTV","newround","a","1=0","2=0")
	register_forward(FM_EmitSound, "EmitSound")
	
	register_cvar("czolganie", VERSION, FCVAR_SERVER|FCVAR_EXTDLL|FCVAR_SPONLY) 
}


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

public cod_class_disabled(id)
{
	ma_klase[id] = false;
}
public newround()
{
	for(new i = 0; i < sizeof moze; i++)
		moze[i] = false
	
	client_cmd(0,"-duck")
}

public client_PostThink(id)
{	
	new button = pev(id,pev_button)
	new oldbuttons = pev(id,pev_oldbuttons)
	
	if(ma_klase[id])
	if(button & IN_USE && oldbuttons & IN_USE && pev(id,pev_watertype) == -1)
	{
		new flags = pev(id,pev_flags)
		
		if(flags & FL_ONGROUND)
		{		
			engfunc(EngFunc_DropToFloor,id)
			
			client_cmd(id,"+duck")
			set_pev(id,pev_waterlevel,5)
			set_pev(id,pev_punchangle,{0.0,0.0,0.0})
			moze[id] = true	;		
		}
		
		if(button & IN_JUMP && moze[id])
		{				
			new Float:vVelocity[3] 				
			pev(id,pev_velocity,vVelocity)
			vVelocity[2] = float(-abs(floatround(vVelocity[2]))) 			
			set_pev(id,pev_velocity,vVelocity)						
			set_pev(id,pev_button,pev(id,pev_button) & ~IN_JUMP)
		}		
	}
	else
	{
		if(moze[id])
		{
			client_cmd(id,"-duck")
			set_pev(id,pev_waterlevel,0)
			moze[id] = false;
		}		
	}	
}

public EmitSound(entity, channel, const sound[])
{
	if(equal(sound,"common/wpn_denyselect.wav"))
		return FMRES_SUPERCEDE
	
	return FMRES_IGNORED
}
