#include <amxmodx>
#include <amxmisc>
#include <fakemeta> // Закомментируйте или удалите, если не хотите использовать модуль fakemeta.

#define PLUGIN		"Yet Another Voteban"
#define VERSION		"1.52"
#define AUTHOR		"AndrewZ/noskill"


#if defined _fakemeta_included
	#define OFFSET_CSMENUCODE	205
#endif


#define MAX_PLAYERS	32		// Максимальное количество игроков на вашем сервере. Вообще-то, можно и не трогать.
#define MSGS_PREFIX	"[Voteban]"	// Префикс для сообщений в чат и для причины бана в банлисте (оставьте как есть, если хотите, чтобы автору было приятно).

#define TID_ENDVOTE 1000

enum
{
	MENU_SOUND_SELECT, // 0
	MENU_SOUND_DENY, // 1
	MENU_SOUND_SUCCESS // 2
}

new g_pcvar_time_default,
	g_pcvar_time,
	g_pcvar_ban_type,
	g_pcvar_delay,
	g_pcvar_duration,
	g_pcvar_percent,
	g_pcvar_min_players,
	g_pcvar_spec_admins,
	g_pcvar_time_access,
	g_pcvar_admin_access,
	g_pcvar_immunity_access

new g_menus_sounds[][] =
{
	"buttons/lightswitch2.wav", // 0
	"buttons/button2.wav", // 1
	"buttons/blip1.wav" // 2
}

new g_user_menu_page[ MAX_PLAYERS + 1 ],
	g_user_menu_players[ MAX_PLAYERS + 1 ][ MAX_PLAYERS ],
	g_user_playerid[ MAX_PLAYERS + 1 ],
	g_user_reason[ MAX_PLAYERS + 1 ][ 26 ],
	g_user_time[ MAX_PLAYERS + 1 ],
	g_user_votes_for_ban[ MAX_PLAYERS + 1 ],
	g_user_start_game_time[ MAX_PLAYERS + 1 ]

new g_ban_id,
	g_reason[ 26 ],
	g_time

new bool:g_started
new g_parsed_time_strings[ 5 ][ 8 ]


public plugin_precache()
{
	static i
	
	for(  i = 0; i < sizeof g_menus_sounds; i ++ )
		precache_sound( g_menus_sounds[ i ] )
}

public plugin_init()
{
	register_plugin( PLUGIN, VERSION, AUTHOR )
	
	g_pcvar_time_default = 		register_cvar( "yav_time_default", "5" )
	g_pcvar_time = 				register_cvar( "yav_time", "5 15 30 60 180" )
	g_pcvar_ban_type = 			register_cvar( "yav_ban_type", "2" )
	g_pcvar_delay = 			register_cvar( "yav_delay", "5" )
	g_pcvar_duration =			register_cvar( "yav_duration", "15" )
	g_pcvar_percent = 			register_cvar( "yav_percent", "60" )
	g_pcvar_min_players = 		register_cvar( "yav_min_players", "3" )
	g_pcvar_spec_admins = 		register_cvar( "yav_spec_admins", "0" )
	g_pcvar_time_access = 		register_cvar( "yav_time_access", "c" )
	g_pcvar_admin_access = 		register_cvar( "yav_admin_access", "d" )
	g_pcvar_immunity_access = 	register_cvar( "yav_immunity_access", "a" )
	
	register_clcmd( "say /voteban", "cmd_voteban_players_menu" )
	register_clcmd( "say_team /voteban", "cmd_voteban_players_menu" )
	register_clcmd( "amx_votebanmenu", "show_voteban_main_menu" )
	
	register_clcmd( "voteban_reason", "cmd_voteban_reason" )
	
	register_menu( "voteban_players_menu", 1023, "handler_voteban_players_menu" )
	register_menu( "voteban_main_menu", -1, "handler_voteban_main_menu" )
	register_menu( "voteban_time_menu", -1, "handler_voteban_time_menu" )
	register_menu( "voteban_menu", -1, "handler_voteban_menu" )

	register_dictionary( "yet_another_voteban.txt" )
}

public plugin_cfg()
{
	new string[ 44 ]; get_pcvar_string( g_pcvar_time, string, 43 )
	
	parse( string,	g_parsed_time_strings[ 0 ], 7, 
					g_parsed_time_strings[ 1 ], 7, 
					g_parsed_time_strings[ 2 ], 7, 
					g_parsed_time_strings[ 3 ], 7,
					g_parsed_time_strings[ 4 ], 7 )
}

public client_connect( id )
	clear_user_voteban_data( id )

public client_disconnect( id )
	clear_user_voteban_data( id )

public clear_user_voteban_data( id )
{
	g_user_menu_page[ id ] = 0
	g_user_playerid[ id ] = 0
	g_user_time[ id ] = get_pcvar_num( g_pcvar_time_default )
	arrayset( g_user_menu_players[ id ], 0, MAX_PLAYERS )
	arrayset( g_user_reason[ id ], 0, 26 )
	
	if( g_ban_id == id )
		clear_voteban_data()
}

public clear_voteban_data()
{
	g_started = false
	g_ban_id = 0
	g_time = 0
	arrayset( g_reason, 0, 26 )
	arrayset( g_user_votes_for_ban, 0, MAX_PLAYERS + 1 )
}

public cmd_voteban_reason( id )
{
	new args[ 26 ]
	read_args( args, 25 )
	remove_quotes( args )
	
	g_user_reason[ id ] = args
	
	show_voteban_main_menu( id )
	
	return PLUGIN_HANDLED
}

public cmd_voteban_players_menu( id )
{
	if( !voteban_available( id ) )
		return PLUGIN_HANDLED

	show_voteban_players_menu( id, 0 )

	return PLUGIN_HANDLED
}

public show_voteban_players_menu( id, page )
{
	if( !voteban_available( id ) )
		return PLUGIN_HANDLED
	
	if( page < 0 )
	{
		clear_user_voteban_data( id )
		return PLUGIN_HANDLED
	}
	
#if defined _fakemeta_included
	set_pdata_int( id, OFFSET_CSMENUCODE, 0 )
#endif
	
	new players[ 32 ], num
	get_players( players, num, "ch" )
	
	new i = min( page * 8, num )
	new start = i - ( i % 8 )
	new end = min( start + 8, num )
	page = start / 8
	
	g_user_menu_page[ id ] = page
	g_user_menu_players[ id ] = players
	
	new menu[ 512 ], item, keys = MENU_KEY_0
	new len = formatex( menu, 511, "\y%L : %L\R%d/%d^n^n", id, "VOTEBAN_MENU_TITLE", id, "VOTEBAN_MENU_PLAYERS_TITLE", page + 1, ( ( num - 1 ) / 8 ) + 1 ) //Голосование за бан || Выбор игрока
	
	for( i = start; i < end; i ++ )
	{
		new name[ 32 ], b_id = players[ i ]
		
		get_user_name( b_id, name, 31 )
		
		if( id == b_id )
			len += formatex( menu[ len ], 511 - len, "\d%d. \y%s^n", ++ item, name )
		
		else 
		{
			new flags[ 23 ]; get_pcvar_string( g_pcvar_immunity_access, flags, 22 )
		
			if( get_user_flags( b_id ) & read_flags( flags ) )
				len += formatex( menu[ len ], 511 - len, "\d%d. %s \r*^n", ++ item, name )
			
			else
			{
				keys |= ( 1 << item )
				len += formatex( menu[ len ], 511 - len, "\w%d. \w%s^n", ++ item, name )
			}
		}
	}
	
	if( end < num )
	{	
		keys |= MENU_KEY_9
		formatex( menu[ len ], 511 - len, "^n\w9. %L^n0. %L", id, "VOTEBAN_MENU_NEXT", id, page ? "VOTEBAN_MENU_BACK" : "VOTEBAN_MENU_EXIT" ) //Туда/Сюда/Выход
	}
	
	else  formatex( menu[ len ], 511 - len, "^n\w0. %L", id, page ? "VOTEBAN_MENU_BACK" : "VOTEBAN_MENU_EXIT" ) // Туда/Выход
	
	show_menu( id, keys, menu, -1, "voteban_players_menu" )
	
	return PLUGIN_HANDLED
}

public handler_voteban_players_menu( id, key )
{
	if( !voteban_available( id ) )
		return PLUGIN_HANDLED

	switch( key )
	{
		case 0..7:
		{
			new temp[ 190 ], b_id = g_user_menu_players[ id ][ g_user_menu_page[ id ] * 8 + key ]
			
			if( is_user_connected( b_id ) )
			{
				new flags[ 23 ]; get_pcvar_string( g_pcvar_immunity_access, flags, 22 )
			
				if( !( get_user_flags( b_id ) & read_flags( flags ) ) )
				{
					g_user_playerid[ id ] = b_id
					show_voteban_main_menu( id )
				}
				else 
					format( temp, charsmax( temp ), "^1[^4%s^1] %L", MSGS_PREFIX, id, "VOTEBAN_IMMUNITY")// Выбранный игрок имеет иммунитет к бану.
			}
			
			else format( temp, charsmax( temp ), "^1[^4%s^1] %L", MSGS_PREFIX, id, "VOTEBAN_LEAVE" ) 		// Выбранный игрок покинул сервер.
			
			yav_print_color( id, temp ) 
		}
		
		case 8: show_voteban_players_menu( id, ++ g_user_menu_page[ id ] )
		case 9: show_voteban_players_menu( id, -- g_user_menu_page[ id ] )
	}
	
	client_spk( id, MENU_SOUND_SELECT )
	
	return PLUGIN_CONTINUE
}

public show_voteban_main_menu( id )
{
	if( !voteban_available( id ) )
		return PLUGIN_HANDLED
	
#if defined _fakemeta_included
	set_pdata_int( id, OFFSET_CSMENUCODE, 0 )
#endif

	new menu[ 256 ], len, 
		keys = MENU_KEY_1 + MENU_KEY_2 + MENU_KEY_4 + MENU_KEY_0, 
		b_id = g_user_playerid[ id ]
	
	len = formatex( menu, charsmax( menu ), "\y%L", id, "VOTEBAN_MENU_TITLE" ) // Голосование за бан

// === 1 ===
	if( is_user_connected( b_id ) )
	{
		new name[ 32 ]; get_user_name( b_id, name, 31 )
		len += formatex( menu[ len ], charsmax( menu ) - len, "^n^n\w1. %L: \y%s", id, "VOTEBAN_MENU_PLAYER", name ) // Игрок
	}
	
	else len += formatex( menu[ len ], charsmax( menu ) - len, "^n^n\w1. %L: \d%L", id, "VOTEBAN_MENU_PLAYER", id, "VOTEBAN_MENU_SELECT_PLAYER" ) // Выбрать игрока
// =========
	

// === 2 ===
	if( g_user_reason[ id ][ 0 ] ) 
		len += formatex( menu[ len ], charsmax( menu ) - len, "^n\w2. %L: \y%s", id, "VOTEBAN_MENU_REASON", g_user_reason[ id ] ) // Причина
		
	else len += formatex( menu[ len ], charsmax( menu ) - len, "^n\w2. %L: \d%L", id, "VOTEBAN_MENU_REASON", id, "VOTEBAN_MENU_ENTER_REASON"  )  // Причина || Ввести причину бана
// =========
	

// === 3 ===

	new flags[ 23 ]; get_pcvar_string( g_pcvar_time_access, flags, 22 )
	
	if( get_user_flags( id ) & read_flags( flags ) )
	{
		keys |= MENU_KEY_3
		len += formatex( menu[ len ], charsmax( menu ) - len, "^n\w3. %L: \y%d %L", id, "VOTEBAN_MENU_TIME", g_user_time[ id ], id, "VOTEBAN_MENU_MINUTES" ) // Время бана || минут
	}
// =========
	
	
	new admins = get_admins_online()
	
	if( admins )
		len += formatex( menu[ len ], charsmax( menu ) - len, "^n^n\w4. %L", id, "VOTEBAN_MENU_NOTIFY", admins ) // Сообщить администратору (\y%d в сети\w)
	else
		len += formatex( menu[ len ], charsmax( menu ) - len, "^n^n\w4. %L", id, "VOTEBAN_MENU_START_VOTE" ) // Начать голосование
	
	len += formatex( menu[ len ], charsmax( menu ) - len, "^n^n0. %L", id, "VOTEBAN_MENU_EXIT" ) // Выход

	show_menu( id, keys, menu, _, "voteban_main_menu" )
	
	return PLUGIN_HANDLED
}

public handler_voteban_main_menu( id, key )
{
	if( !voteban_available( id ) )
		return PLUGIN_HANDLED
	
	key ++
	switch( key )
	{
		case 1:
		{
			show_voteban_players_menu( id, 0 )
			client_spk( id, MENU_SOUND_SELECT )
		}
		
		case 2: 
		{
			client_cmd( id, "messagemode voteban_reason" )
			client_spk( id, MENU_SOUND_SELECT )
		}
		
		case 3:
		{
			show_voteban_time_menu( id )
			client_spk( id, MENU_SOUND_SELECT )
		}
		
		case 4:
		{
			new b_id = g_user_playerid[ id ]
			new temp[ 190 ]
			
			if( !is_user_connected( b_id ) )
			{
				format( temp, charsmax( temp ), "^1[^4%s^1] %L", MSGS_PREFIX, id, "VOTEBAN_NEED_PLAYER" )// Вы должны выбрать игрока
				yav_print_color( id,  temp )
				show_voteban_main_menu( id )
				
				client_spk( id, MENU_SOUND_DENY )
			}
			
			else if( !g_user_reason[ id ][ 0 ] )
			{
				format( temp, charsmax( temp ), "^1[^4%s^1] %L", MSGS_PREFIX, id, "VOTEBAN_NEED_REASON" ) // Вы должны ввести причину бана
				yav_print_color( id, temp )
				show_voteban_main_menu( id )
				
				client_spk( id, MENU_SOUND_DENY )
			}
			
			else
			{	
				new admins = get_admins_online()
				
				if( admins )
				{
					new str[ 190 ], i
					
					for( i = 1; i <= MAX_PLAYERS; i ++ )
					{
						new flags[ 23 ]; get_pcvar_string( g_pcvar_admin_access, flags, 22 )
		
						if( is_user_connected( i ) && get_user_flags( i ) & read_flags( flags ) )
						{
							new b_name[ 32 ]; get_user_name( b_id, b_name, 31 )
							new name[ 32 ]; get_user_name( id, name, 31 )
							format( str, charsmax( str ), "^1[^4%s^1] %L", MSGS_PREFIX, i, "VOTEBAN_ADMIN_NOTIFICATION", name, b_name, g_user_reason[ id ] )// %s хочет забанить %s за "%s".
							yav_print_color( i, str ) 
							
							client_spk( i, MENU_SOUND_SUCCESS )
						}
					}
					
					format( temp, charsmax( temp ), "^1[^4%s^1] %L", MSGS_PREFIX, id, "VOTEBAN_ADMIN_NOTIFIED", admins )// Администраторов уведомлено о вашей жалобе: %d.
					yav_print_color( id,  temp )
					client_spk( id, MENU_SOUND_SUCCESS )
					clear_user_voteban_data( id )
					
					return PLUGIN_HANDLED
				}
				
				g_ban_id = b_id
				g_reason = g_user_reason[ id ]
				
				new flags[ 23 ]; get_pcvar_string( g_pcvar_time_access, flags, 22 )
				
				if( get_user_flags( id ) & read_flags( flags ) )
					g_time = g_user_time[ id ]
				
				else g_time = get_pcvar_num( g_pcvar_time_default )
				
				clear_user_voteban_data( id )
				show_voteban_menu( id )
				
				g_user_start_game_time[ id ] = floatround( get_gametime() )
				
				set_task( get_pcvar_float( g_pcvar_duration ), "task_end_vote", TID_ENDVOTE )
				g_started = true
			}
		}
		
		case 10:
		{
			clear_user_voteban_data( id )
			client_spk( id, MENU_SOUND_SELECT )
		}
	}
	
	return PLUGIN_CONTINUE
}

public show_voteban_time_menu( id )
{
	new menu[ 256 ], item, len, keys = MENU_KEY_0
	
	len = formatex( menu, charsmax( menu ), "\y%L : %L^n\w", id, "VOTEBAN_MENU_TITLE", id, "VOTEBAN_MENU_TIME_TITLE" ) // Голосование за бан || Выбор срока бана

	for( new i; i < sizeof g_parsed_time_strings; i ++ )
	{
		if( !g_parsed_time_strings[ i ][ 0 ] )
			break
		
		keys |= ( 1 << item )
		len += formatex( menu[ len ], charsmax( menu ) - len, "^n%d. %s %L", ++ item, g_parsed_time_strings[ i ], id, "VOTEBAN_MENU_MINUTES" ) // минут
	}
	
	len += formatex( menu[ len ], charsmax( menu ) - len, "^n^n0. %L", id, "VOTEBAN_MENU_EXIT" ) // выход

	show_menu( id, keys, menu, _, "voteban_time_menu" )
}

public handler_voteban_time_menu( id, key )
{
	if( !voteban_available( id ) )
		return PLUGIN_HANDLED
	
	switch( key )
	{
		case 0..4: g_user_time[ id ] = str_to_num( g_parsed_time_strings[ key ] )
		
		case 9:
		{
			clear_user_voteban_data( id )
			return PLUGIN_HANDLED
		}
	}
	
	show_voteban_main_menu( id )
	client_spk( id, MENU_SOUND_SELECT )
	
	return PLUGIN_CONTINUE
}

public show_voteban_menu( id )
{
	new v_id, temp[ 190 ]
	
	for( v_id = 1; v_id <= MAX_PLAYERS; v_id ++ )
	{
		if( is_user_connected( v_id ) )
		{
#if defined _fakemeta_included
			set_pdata_int( v_id, OFFSET_CSMENUCODE, 0 )
#endif
			new b_id = g_ban_id
			
			if( v_id != b_id )
			{
				client_spk( v_id, MENU_SOUND_SUCCESS )
				
				new name[ 32 ]; get_user_name( id, name, 31 )
				new player_name[ 32 ]; get_user_name( b_id, player_name, 31 )
				format( temp, charsmax( temp ), "^1[^4%s^1] %s %L %s!", MSGS_PREFIX, name, v_id, "VOTEBAN_WHO_START", player_name)
				yav_print_color( v_id, temp ) // начал голосование за бан
				
				new menu[ 256 ], len, keys = MENU_KEY_1 + MENU_KEY_2 + MENU_KEY_3 + MENU_KEY_4
				
				len = formatex( menu, charsmax( menu ), "\y%L", v_id, "VOTEBAN_MENU_TITLE" ) // Голосование за бан
				
				len += formatex( menu[ len ], charsmax( menu ) - len, "^n^n\w%L", v_id, "VOTEBAN_MENU_VOTE_FOR", player_name, g_time ) // Забанить \y%s \wна \y%d\w минут?
				len += formatex( menu[ len ], charsmax( menu ) - len, "^n\w%L: \y%s", v_id, "VOTEBAN_MENU_REASON", g_reason ) // Причина
				
				len += formatex( menu[ len ], charsmax( menu ) - len, "^n^n%L", v_id, "VOTEBAN_MENU_NO_YES" ) // \w1. Нет^n2. Нет^n3. Нет^n4. \rДа
				
				show_menu( v_id, keys, menu, _, "voteban_menu" )
			}
		}
	}
}

public handler_voteban_menu( v_id, key )
{
	key ++
	
	if( key == 4 )
		add_vote( v_id )
	
	client_spk( v_id, MENU_SOUND_SELECT )
}

public add_vote( v_id )
{
	if( !is_user_connected( v_id ) )
		return PLUGIN_HANDLED
		
	new b_id = g_ban_id
	
	if( !is_user_connected( b_id ) )
		return PLUGIN_HANDLED
	
	if( !g_started )
	{
		new temp[ 190 ]
		format( temp, charsmax( temp ), "^1[^4%s^1] %L", MSGS_PREFIX, v_id, "VOTEBAN_ALREADY_FINISHED" ) // Голосование уже закончено.
		yav_print_color( v_id, temp )
		return PLUGIN_HANDLED
	}

	
	g_user_votes_for_ban[ b_id ] ++
	
	static total_votes, need_votes
	total_votes = g_user_votes_for_ban[ b_id ]
	need_votes = get_pcvar_num( g_pcvar_percent ) * get_players_num() / 100
	
	if( total_votes < need_votes )
	{
		new name[ 32 ], id
		
		get_user_name( b_id, name, 31 )
		
		for( id = 1; id <= MAX_PLAYERS; id ++ )
		{
			if( is_user_connected( id ) )
			{
				if( id != b_id )
					client_print( id, print_center, "%L", id, "VOTEBAN_VOTE", name, total_votes, need_votes ) // За бан %s проголосовало: %d, нужно: %d.
			}
		}
	}
	
	else ban_player( b_id )
	
	return PLUGIN_CONTINUE
}

public ban_player( b_id )
{
	remove_task( TID_ENDVOTE )
	
	if( is_user_connected( b_id ) )
	{
		new name[ 32 ], ip[ 16 ], authid[ 35 ], userid, time, id, temp[ 190 ]
		
		get_user_name( b_id, name, 31 )
		get_user_ip( b_id, ip, 15, 1 )
		get_user_authid( b_id, authid, 34 )
		userid = get_user_userid( b_id )
		time = g_time
		
		switch( get_pcvar_num( g_pcvar_ban_type ) )
		{
			case 1: server_cmd( "amx_ban %d ^"%s^" ^"[%s] %s^"", time, authid, MSGS_PREFIX, g_reason ) // AMXBANS
			case 2: server_cmd( "fb_ban %d #%d ^"[%s] %s^"", time, userid, MSGS_PREFIX, g_reason ) // FRESH BANS
			case 3: server_cmd( "amx_ban ^"%s^" %d ^"[%s] %s^"", authid, time, MSGS_PREFIX, g_reason ) // ADVANCED BANS
			case 4: server_cmd( "amx_superban #%d %d ^"[%s] %s^"", userid, time, MSGS_PREFIX, g_reason ) // SUPERBAN
			case 5: server_cmd( "addip %d %s", time, ip ) // BAN IP
			case 6: server_cmd( "banid %d ^"%s^" kick", time, authid ) // BAN AUTHID (STEAMID)
		}
		
		for( id = 1; id <= MAX_PLAYERS; id ++ )
		{
			if( is_user_connected( id ) )
			{
				if( id != b_id )
				{
					format( temp, charsmax( temp ), "^1[^4%s^1] %s %L", MSGS_PREFIX, name, id, "VOTEBAN_BANNED" )
					yav_print_color( id,  temp ) // забанен через голосование!
				}
			}
		}
	}
	
	clear_voteban_data()
}

public task_end_vote()
{
	new temp[ 190 ], id
	
	for( id = 1; id <= MAX_PLAYERS; id ++ )
	{
		if( is_user_connected( id ) )
		{
			format( temp, charsmax( temp ), "^1[^4%s^1] %L", MSGS_PREFIX, id, "VOTEBAN_ENDED" ) // Голосование за бан провалено.
			yav_print_color( id, temp ) 
		}
	}
	
	clear_voteban_data()
	
	g_started = false
}

public voteban_available( id )
{
	new user_flags, flags[ 2 ][ 23 ], temp[ 190 ]

	if( g_started )
	{
		
		format( temp, charsmax( temp ), "^1[^4%s^1] %L", MSGS_PREFIX, id, "VOTEBAN_ALREADY_STARTED" )// В данный момент уже идёт голосование.
		yav_print_color( id, temp )
		return 0
	}
	
	user_flags = get_user_flags( id )
	get_pcvar_string( g_pcvar_admin_access, flags[ 0 ], 22 )
	get_pcvar_string( g_pcvar_time_access, flags[ 1 ], 22 )
	
	if( user_flags & read_flags( flags[ 0 ] ) )
	{
		format( temp, charsmax( temp ), "^1[^4%s^1] %L", MSGS_PREFIX, id, "VOTEBAN_YOU_ADMIN" )
		yav_print_color( id, temp )// Используйте своё бан-меню.
		return 0
	}
	
	if( g_user_start_game_time[ id ] )
	{
		static interim, delay_cvar
		
		interim = floatround( get_gametime() ) - g_user_start_game_time[ id ]
		delay_cvar = get_pcvar_num( g_pcvar_delay )
		
		if( flags[ 1 ][ 0 ] && ( user_flags & read_flags( flags[ 1 ] ) ) )
			return 1
		
		else if( interim < delay_cvar * 60 )
		{
			format( temp, charsmax( temp ), "^1[^4%s^1] %L", MSGS_PREFIX, id, "VOTEBAN_DELAY", ( delay_cvar - ( interim / 60 ) ) + 1 ) // Вы должны подождать еще %d мин. после предыдущего голосования.
			yav_print_color( id, temp )
			return 0
		}
	}
	
	if( get_players_num() < get_pcvar_num( g_pcvar_min_players ) )
	{
		format( temp, charsmax( temp ), "^1[^4%s^1] %L", MSGS_PREFIX, id, "VOTEBAN_NOT_ENOUGH_PLAYERS" ) // Недостаточно игроков, чтобы начать голосование.
		yav_print_color( id, temp )
		return 0
	}

	return 1
}

stock get_admins_online()
{
	new admins, i, team
	
	admins = 0
	
	for( i = 1; i <= MAX_PLAYERS; i ++ )
	{
		new flags[ 23 ]; get_pcvar_string( g_pcvar_admin_access, flags, 22 )
		
		if( !is_user_connected( i ) )
			continue
		
		if( !( get_user_flags( i ) & read_flags( flags ) ) )
			continue
			
		if( get_pcvar_num( g_pcvar_spec_admins ) )		
			admins ++
		else
		{
			team = get_user_team( i )
			
			if( !( ( team == 2 ) || ( team ==1 ) ) )
				continue
				
			admins ++
		}
	}
	
	return admins
}

stock get_players_num()
{
	static num, id, team
	num = 0
	
	for( id = 1; id <= MAX_PLAYERS; id ++ )
	{
		if( !is_user_connected( id ) )
			continue
			
		if( is_user_bot( id ) )
			continue
		
		team = get_user_team( id )
		
		if( !( ( team == 2 ) || ( team == 1 ) ) )
			continue

		num ++
	}
	return num
}

stock client_spk( id, sound_id )
	client_cmd( id, "spk %s", g_menus_sounds[ sound_id ] )

stock yav_print_color( const id, const input[], any:... )
{
#if AMXX_VERSION_NUM < 183
	new num = 1, players[ 32 ]
	static msg[ 191 ]
	vformat( msg, 190, input, 3 )
    
	replace_all( msg, 190, "!g", "^4" ) // Green Color
	replace_all( msg, 190, "!n", "^1" ) // Default Color
	replace_all( msg, 190, "!t", "^3" ) // Team Color
    
	if( id ) players[ 0 ] = id; else get_players( players, num, "ch" )
	{
		static i
		for( i = 0; i < num; i ++ )
		{
			if( is_user_connected( players[ i ] ) )
			{
				message_begin( MSG_ONE_UNRELIABLE, get_user_msgid( "SayText" ), _, players[ i ] )
				write_byte( players[ i ] )
				write_string( msg )
				message_end()
			}
		}
	}
#else
	client_print_color( id, print_team_default, input )
#endif
	return 0
	
}