#include <amxmodx>
#include <jailbreak>
#include <fun>
#include <hamsandwich>

#define PLUGIN "Rekin"
#define VERSION "1.0"
#define AUTHOR "HubertTM"

new id_zabawy
new dzien

public plugin_init() {
	
	register_plugin(PLUGIN, VERSION, AUTHOR)
	
	id_zabawy = jail_register_game("Rekin"); 
	RegisterHam(Ham_Killed, "player", "PlayerKilled", 1);
}


public OnDayStartPre(day, szInfo[256], szInfo2[512], setting[10], gTimeRound)
{	
	dzien = day;
	new szTime[12];
	
	if(day == id_zabawy)	
	{
		format_time(szTime, 11, "%M:%S", gTimeRound-60); 
		
		formatex(szInfo2, 511, "Zasady:^n%s - Straznicy vs. Rekiny^nRekiny maja noclipa!^nStraznicy kampia!^nDuszek za zabicie Straznika!", szTime); 
		
		szInfo = "Dzisiaj jest Dzien Rekina"; 
		
		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[4] = 1;  
		setting[7] = 2;
	}
}



public OnDayStartPost(day)
{
	dzien = day;
	
	if(day == id_zabawy)	
	{		
		jail_set_game_hud(45, "Otworzenie Cel + Noclip za:");
	}
}



public OnGameHudEnd()
{
	
	if(jail_get_play_game_id() == id_zabawy)
	{
		jail_open_cele();
		
		jail_set_ct_hit_tt(false);
		jail_set_tt_hit_ct(false);
		
		set_task(3.0, "Powtarzaj", 1, _,_, "b");
		
		for(new i=1; i<33; i++)
			if(is_user_alive(i) && get_user_team(i) == 1)
			set_user_noclip(i, 1);
	}
	
}

public OnRemoveData(day)
	remove_task(1);
	
public Powtarzaj()
{
	if(dzien != id_zabawy)
	remove_task(1);
	
	for(new i=1; i<33; i++)
		if(is_user_alive(i) && get_user_team(i) == 1)
			user_slap(i, random_num(1,2), 0);
	
}

public PlayerKilled(this, attacker, shouldgib)
{
	if(dzien != id_zabawy)
	return;
	
	if(!is_user_connected(this) || !is_user_connected(attacker))
	return;
	
	if(get_user_team(attacker) != 1 || get_user_team(this) != 2)
	return;
	
	
	new name[32];
	get_user_name(attacker, name, 31);
	
	client_print(0, 3, "[YO TEXT] Rekin %s dostaje Duszka za zabicie straznika!", name);
	
	jail_set_prisoner_ghost(attacker, false, true);
}