#include <amxmodx>
#include <amxmisc>
#include <fun>
#include <jailbreak>

#define PLUGIN "[JB] Dzieci Wojny"
#define VERSION "1.0"
#define AUTHOR "Cypis"

new id_zabawa;
public plugin_init() {
	register_plugin(PLUGIN, VERSION, AUTHOR)

	id_zabawa = jail_register_game("Dzieci wojny");
}

public OnDayStartPre(day, szInfo[256], szInfo2[512], setting[10], gTimeRound)
{	
	static szTime[12];
	if(day == id_zabawa)
	{
		format_time(szTime, 11, "%M:%S", gTimeRound-30);
		formatex(szInfo2, 511, "Zasady:^nStraznicy maja czas do %s na schownie sie^nO %s otwieraja sie cele - CT vs TT", szTime, szTime);
		szInfo = "Dzieci wojny";
		
		jail_set_prisoners_micro(true, true);
		jail_set_ct_hit_tt(true);
		jail_set_tt_hit_ct(true);
		
		setting[0] = 2;
		setting[1] = 1;
		setting[2] = 1;
		setting[6] = 1;
		setting[7] = 3;
		
		new ile_graczy[2];
		for(new i=1; i<=MAX; i++)
		{
			if(!is_user_connected(i) || !is_user_alive(i))
				continue;
				
			switch(get_user_team(i))
			{
				case 1: 
				{
					ile_graczy[0]++;
					jail_set_user_menuweapons(i, true, false);
				}
				case 2: ile_graczy[1]++;
			}
		}
		if(ile_graczy[0])
		{
			for(new i=1; i<=MAX; i++)
			{
				if(!is_user_connected(i) || !is_user_alive(i) || get_user_team(i) != 2)
					continue;
				
				set_user_health(i, ile_graczy[0]*150/ile_graczy[1]);
			}
		}
	}
}

public OnDayStartPost(day)
{
	if(day == id_zabawa)
	{
		jail_set_game_hud(30, "Rozpoczecie zabawy za");
	}
}

public OnGameHudEnd(day)
{
	if(day == id_zabawa)
	{
		jail_open_cele();
		jail_set_ct_hit_tt(false);
		jail_set_tt_hit_ct(false);
	}
}
