#include <amxmodx>

#define R random(256)
#define G random(256)
#define B random(256)
#define time_hud 10.0

new round_count, msgsaytext
new cvar_show_msg, cvar_nextmap

public plugin_init()
{
	register_plugin("Round Info", "0.2", "P.Of.Pw")
	
	register_event("TextMsg", "game_comenc", "a", "2&#Game_C")

	register_logevent("roundstart", 2, "1=Round_Start")
	
	cvar_show_msg = register_cvar("round_msg", "1") // 1- msg chat color ; 2-msg hud
	cvar_nextmap = get_cvar_pointer("amx_nextmap")

	msgsaytext = get_user_msgid("SayText")
}

public game_comenc() 
{ 
	round_count = 0
}

public roundstart()
{
	new nextmap[32]
	get_pcvar_string(cvar_nextmap, nextmap, 31)

	new current_map[32]
	get_mapname(current_map, 31)

	new playersnum = get_playersnum()
	new maxplayers = get_maxplayers()
	
	if (get_pcvar_num(cvar_show_msg) == 1)
	{
		print_color(0, "^x01--[ ^x04Раунд: ^x03%d ^x01| ^x04Игроки: ^x03%d/%d ^x04Карта: ^x03%s ^x01| ^x04Следущая: ^x03%s ^x01]--",
		round_count+=1, playersnum, maxplayers, current_map, nextmap)
	}

	else if (get_pcvar_num(cvar_show_msg) == 2)
	{
		set_hudmessage(R, G, B, -1.0, 0.4, 0, 6.0, time_hud)
		show_hudmessage(0, "--[ Round: %d | Players: %d/%d^n Map: %s | Nextmap: %s ]--",
		round_count+=1, playersnum, maxplayers, current_map, nextmap)
	}
}

stock print_color(id, const message[], {Float,Sql,Result,_}:...)
{
	new Buffer[128],Buffer2[128],
	players[32], index, num, i

	formatex(Buffer2, sizeof Buffer2 - 1, "%s", message)
	vformat(Buffer, sizeof Buffer - 1, Buffer2, 3)
	get_players(players, num, "c")

	if (id) 
	{
		message_begin(MSG_ONE, msgsaytext, _, id)
		write_byte(id)
		write_string(Buffer)
		message_end()
	} 

	else 
	{
		for (i = 0; i < num;i++)
		{
			index = players[i]
			if (!is_user_connected(index)) 
				continue

			message_begin(MSG_ONE,msgsaytext,_,index)
			write_byte(index)
			write_string( Buffer )
			message_end()
		}
	}
}