
public event_restart_attempt()
{
	if(get_pcvar_num(cvar_bleach) != 1 || !get_playersnum()) return PLUGIN_CONTINUE;
		
	new players[MAXPLAYERS];
	static num;
	
	get_players(players,num,"ah");
	for (new i; i < num; ++i)
	{
		g_restart_attempt[players[i]]=true;
	}
	
	return PLUGIN_CONTINUE;
}

public event_hud_reset(id)
{
	if(get_pcvar_num(cvar_bleach) != 1) return PLUGIN_CONTINUE;
	
	remove_status_icon(id);
	set_user_rendering(id);
	
	if(g_event_round_end)
	{
		g_event_round_end=false;
		g_event_freeze_time=true;
	}
	
	if(!g_event_buy_time)
	{
		g_event_buy_time = true;
		set_task(get_cvar_float("mp_buytime")*60.0,"buy_time_over",BLEACH_TASK_BUYTIME);
	}
	
	if(g_restart_attempt[id])
	{
		g_restart_attempt[id]=false;
		return PLUGIN_CONTINUE;
	}
	
	if(!task_exists(BLEACH_TASK_SPIRIT,0))
	{
		set_task(5.0,"spirit_regenerate",BLEACH_TASK_SPIRIT,"",0,"b");
		reset_player_all();
		database_init();
	}
	
	event_player_spawn(id);
	
	return PLUGIN_CONTINUE;
}

public event_first_spawn(id)
{
	client_print(id,print_chat,"%L",id,"L_GAME_WELCOME",PLUGIN_TAG);
	menu_print_classes(id);
}

public event_player_spawn(id)
{
	if(g_player_first_spawn[id])
	{
		event_first_spawn(id);
	}
	else if(g_player_class[id]==0)
	{
		menu_print_classes(id);
	}
	
	g_player_max_health[id]=DEFAULT_MAX_HEALTH;
	g_player_max_armour[id]=DEFAULT_MAX_ARMOUR;
	
	if(cs_get_user_vip(id))
	{
		g_player_max_armour[id]+=100;
	}
	
	if(g_skill[id][P_SKILL_5] > 0 && g_player_class[id] == 2)
	{
		static armor,CsArmorType:armor_type;
		armor=cs_get_user_armor(id,armor_type);
		if(armor < g_skill[id][P_SKILL_5]*15)
		{
			static armor_bonus;
			armor_bonus = g_skill[id][P_SKILL_5]*15;
			cs_set_user_armor(id,armor_bonus,armor_type);
			g_player_max_armour[id]+=armor_bonus;
		}
	}
	
	validate_gravity(id);
	set_user_health(id,g_player_max_health[id]+g_player_endurance[id]);
	
	restore_player(id);
	restore_cooldowns(id);
}

public event_bartime(id)
{
	if(get_pcvar_num(cvar_bleach) != 1) return PLUGIN_CONTINUE;

	new bartime = read_data(1);

	if (bartime == 3) g_player_planter=id;
	else if (bartime == 5 || bartime == 10) g_player_defuser=id;
	else if (bartime == 0)
	{
		if (id == g_player_planter) g_player_planter=0;

		if (id == g_player_defuser) g_player_defuser=0;
	}
	
	return PLUGIN_CONTINUE;
}

public event_zoom(id)
{
	if(get_pcvar_num(cvar_bleach) != 1) return PLUGIN_CONTINUE;

	if (read_data(1) < 90)
	{
		g_player_zoomed[id] = true;
	}
	else
	{
		g_player_zoomed[id] = false;
	}

	return PLUGIN_CONTINUE;
}

public event_current_weapon(id)
{
	if(get_pcvar_num(cvar_bleach) != 1) return PLUGIN_CONTINUE;
	
	if(!g_event_freeze_time)
	{
		validate_max_speed(id);
	}
	
	return PLUGIN_CONTINUE;
}

public event_item_pickup(id)
{
	if(get_pcvar_num(cvar_bleach) != 1) return PLUGIN_CONTINUE;
	
	new item_name[32];
	read_data(1,item_name,31);
	
	if((equal(item_name,"item_assaultsuit") || equal(item_name,"item_kevlar")) &&  cs_get_user_buyzone(id))
	{
		if(g_skill[id][P_SKILL_5] > 0)
		{
			static armor,CsArmorType:armor_type;
			armor=cs_get_user_armor(id,armor_type);
			cs_set_user_armor(id,armor+g_skill[id][P_SKILL_5]*15,armor_type);
		}
	}
	
	return PLUGIN_CONTINUE;
}
