#include <amxmodx>
#include <fun>
#include <zombieplague>
#include <hamsandwich>
#include <myaddon>
#include <fakemeta>
#include <playermodel>
#include <dhudmessage>

#define PLUGIN "[ZP] Hero in Round"
#define VERSION "1.1"
#define AUTHOR "Santa"

new g_maxplayers,SayText
new g_sprite

public plugin_init()
{
	register_plugin(PLUGIN, VERSION, AUTHOR)
	g_maxplayers = get_maxplayers()
	SayText = get_user_msgid("SayText")
}
public plugin_precache()
{
precache_model("models/player/hero_in_round/hero_in_round.mdl")
}
public zp_round_started(round)
{
if(round == MODE_MULTI || round == MODE_INFECTION)
{
set_task(1.0,"make_hero_in_round")
}
}
public make_hero_in_round(id)
{
	new id
	static iPlayersnum
	iPlayersnum = fnGetAlive()

	id = fnGetRandomAlive(random_num(1, iPlayersnum))

	new name[32]
	get_user_name(id, name, 31)

	set_dhudmessage(0, 255, 0, -1.0, -1.0)
	show_dhudmessage(id, "%s is a Hero...")
	fm_set_user_model(id,"hero_in_round")
	set_user_maxspeed(id, 340)
         set_user_gravity(id, 600)
	set_user_armor(id, 500)
         set_user_health(id, 1000)
	give_weapon_dd(id)
	give_weapon_svdex(id)

}
fnGetRandomAlive(n)
{
	static iAlive, id
	iAlive = 0
	
	for (id = 1; id <= g_maxplayers; id++)
	{
		if (is_user_alive(id) && !zp_get_user_zombie(id))
			iAlive++
		
		if (iAlive == n)
			return id;
	}
	
	return -1;
}
fnGetAlive()
{
	static iAlive, id
	iAlive = 0
	
	for (id = 1; id <= g_maxplayers; id++)
	{
		if (is_user_alive(id) && !zp_get_user_zombie(id))
			iAlive++
	}
	
	return iAlive;
}
stock print_col_chat(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, "!t", "^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, SayText, _, players[i]);  
write_byte(players[i]);  
write_string(msg);  
message_end();  
}  
}  
}  
} 
