#include <amxmodx>
#include <codmod>
#include <hamsandwich>
#include <cstrike>


new bool: ma_klase[33];

new CT_Skins[4][] = {"sas","gsg9","urban","gign"};

new Terro_Skins[4][] = {"arctic","leet","guerilla","terror"};

new const nazwa[] = "Grabarz";
new const opis[] = "Ubranie Wroga, 1/5 szansy na zrespienie sie u wroga";
new const bronie = 1<<CSW_M4A1|1<<CSW_MAC10;
new const zdrowie = 20;
new const kondycja = 5;
new const inteligencja = 0;
new const wytrzymalosc = 0;



public plugin_init()
{
	register_plugin(nazwa, "1.0", "Play");
	
	cod_register_class(nazwa, opis, bronie, zdrowie, kondycja, inteligencja, wytrzymalosc);
	RegisterHam(Ham_Spawn, "player", "Spawn", 1);
	
}
public cod_class_enabled(id){

	ZmienUbranie(id, 0);
	ma_klase[id] = true;
}

public cod_class_disabled(id){

	ZmienUbranie(id, 1);
	ma_klase[id] = false;
}

public ZmienUbranie(id,reset){

	if (!is_user_connected(id))

		return PLUGIN_CONTINUE;

	if (reset)

		cs_reset_user_model(id);

	else

	{
		new num = random_num(0,3);

		cs_set_user_model(id, (get_user_team(id) == 1)? CT_Skins[num]: Terro_Skins[num]);
	}

	return PLUGIN_CONTINUE;
}

public Spawn(id)
{
	if(!is_user_alive(id))
		return;
	
	if(!ma_klase[id])
		return;
	
	if(random_num(1,5) == 1)
	{
		new CsTeams:team = cs_get_user_team(id);
		
		cs_set_user_team(id, (team == CS_TEAM_CT)? CS_TEAM_T: CS_TEAM_CT);
		ExecuteHam(Ham_CS_RoundRespawn, id);
		
		cs_set_user_team(id, team);
	}
}

