/* Plugin generated by AMXX-Studio */

#include <amxmodx>

#define NAME		"[BOSS] Vote"
#define VERSION		"1.2"
#define AUTHOR		"Alexander.3"

#define VOTE		12
#define MAP_BOSS	"zl_boss_alien"

new bool:Vote[33]
new bool:Vote_Complete
new Vote_Num

public plugin_init() {
	register_plugin(NAME, VERSION, AUTHOR)
	register_logevent("NextMaps", 2, "1=Round_End")
	register_clcmd("say /alien", "VoteBoss")
	Vote_Num = VOTE
}

public VoteBoss(id) {
	new Name[32]
	if(Vote[id]) {
		ChatColor(id, "!g[Alien Boss] !yJuz Glosowales na !gAliena!y!")
		return
	}
	Vote[id] = true
	
	Vote_Num--
	get_user_name(id, Name, 31)
	
	if(Vote_Num > 0) {
		ChatColor(0, "!g[Alien Boss] !yZaglosowales na !gAliena! !y(Potrzeba jeszcze !g%d !yGlosow)", Vote_Num)
		ChatColor(0, "!g[Alien Boss] !yWpisz na czacie !g/alien !yAby zaglosowac na !gAliena!y!")
	} else {
		set_hudmessage(255, 0, 0, 0.12, 0.19, 0, 6.0, 12.0)
		show_hudmessage(id, "[Alien Boss]^nGlosowanie zakonczone sukcesem!^nPo tej rundzie starcie z Alienem!")
		Vote_Complete = true
	}	
}

public NextMaps()
	if(Vote_Complete)
		server_cmd("changelevel ^"%s^"", MAP_BOSS)

public client_disconnect(id)
	if(Vote[id]){
		Vote_Num++
		Vote[id] = false
}

stock ChatColor(const id, const input[], any:...) {
	new count = 1, players[32]
	static msg[191]
	vformat(msg, 190, input, 3)
	replace_all(msg, 190, "!g", "^4") // Green Color
	replace_all(msg, 190, "!y", "^1") // Default Color
	replace_all(msg, 190, "!team", "^3") // Team Color
	if (id) players[0] = id; else get_players(players, count, "ch"); {
		for (new i = 0; i < count; 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();
			}
		}
	}
}
	
/* AMXX-Studio Notes - DO NOT MODIFY BELOW HERE
*{\\ rtf1\\ ansi\\ deff0{\\ fonttbl{\\ f0\\ fnil Tahoma;}}\n\\ viewkind4\\ uc1\\ pard\\ lang1049\\ f0\\ fs16 \n\\ par }
*/
