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

#define DMG_BULLET (1<<1)
        
new const nazwa[]   = "Szpieg (Premium)";
new const opis[]    = "Posiada AUG, 1/1 AWP, Niewidka podczas Kucania na nozu";
new const bronie    = 1<<CSW_AUG | 1<<CSW_AWP | 1<<CSW_DEAGLE;
new const zdrowie   = 0;
new const kondycja  = 0;
new const inteligencja = 0;
new const wytrzymalosc = 0;
    
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_Niewidzialnosc", 1);
	RegisterHam(Ham_TakeDamage, "player", "TakeDamage");
}


public cod_class_enabled(id)
{
	if(!(get_user_flags(id) & ADMIN_LEVEL_B))
	{
		ColorChat(id, NORMAL, "[^x04 Katujemy.eu^x01] Nie masz uprawnien, aby uzywac Klasy:^x03 Szpieg");
		return COD_STOP;
	}
	ma_klase[id] = true;
	return COD_CONTINUE;
}	
public cod_class_disabled(id)
{
	set_rendering(id,kRenderFxNone, 0, 0, 0, kRenderTransAlpha, 255);
    	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_team(this) != get_user_team(idattacker) && get_user_weapon(idattacker) == CSW_AWP && damagebits & DMG_BULLET)
		cod_inflict_damage(idattacker, this, float(get_user_health(this))-damage+1.0, 0.0, idinflictor, damagebits);
		
	return HAM_IGNORED;
}
//Przy kucaniu
public fwPrethink_Niewidzialnosc(id)
{
	if(!ma_klase[id])
		return;

	new button = get_user_button(id);
	if( button & IN_DUCK && get_user_weapon(id) == CSW_KNIFE)
	{
		set_rendering(id,kRenderFxNone, 0, 0, 0, kRenderTransAlpha, 1);
	}
	else
	{
		set_rendering(id,kRenderFxNone, 0, 0, 0, kRenderTransAlpha, 255);
	}
}
