#include <amxmodx>
#include <zombieplague>

#define PLUGIN "[ZP] Team win score"
#define VERSION "1.3"
#define AUTHOR "Ryokin"

new g_zombiescore, g_humanscore, g_NoOneWin, g_hudcolor,g_hudposition //, g_msgsync

public plugin_init()
{
	register_plugin(PLUGIN, VERSION, AUTHOR)
	set_task(0.5, "show_hud", _, _, _, "b")
	register_event("TextMsg", "RestartRound", "a", "2&#Game_C", "2&#Game_w")
	g_NoOneWin = register_cvar( "zp_winnoone_score", "1")
	g_hudcolor = register_cvar( "zp_teamscore_hudcolor", "255 25 0")
	g_hudposition = register_cvar( "zp_teamscore_hudposition", "-1.0 0.02")
//	g_msgsync = CreateHudSyncObj()
}

public zp_round_ended(team)
{
	switch(team)
	{
		case WIN_ZOMBIES: g_zombiescore += 1
		
		case WIN_HUMANS: g_humanscore += 1
		
		case WIN_NO_ONE: 
			if (get_pcvar_num(g_NoOneWin))
				g_humanscore += 1	
	}
}

public show_hud()
{
	new hud_red,hud_green,hud_blue, Float:hud_x, Float:hud_y

	new color[16], red[4], green[4], blue[4]
	get_pcvar_string(g_hudcolor, color, 15)
	parse(color, red, 3, green, 3, blue, 3)
		
	hud_red = str_to_num(red)
	hud_green = str_to_num(green)
	hud_blue = str_to_num(blue)

	new Position[19], PositionX[6], PositionY[6]
	get_pcvar_string(g_hudposition, Position, 18)
	parse(Position, PositionX, 6, PositionY, 6)
	
	hud_x = str_to_float(PositionX)
	hud_y = str_to_float(PositionY)

	set_hudmessage(hud_red, hud_green, hud_blue, hud_x, hud_y, 0, 6.0, _, 0.1, 0.2, -1)
//	ShowSyncHudMsg(0, g_msgsync, "[Зомби] VS [Люди]^n[%s%d] -- [%s%d]",g_zombiescore >= 10 ? "" : "0",g_zombiescore,g_humanscore >= 10 ? "" : "0", g_humanscore )
	show_hudmessage(0, "[Зомби] VS [Люди]^n[%s%d] -- [%s%d]",g_zombiescore >= 10 ? "" : "0",g_zombiescore,g_humanscore >= 10 ? "" : "0", g_humanscore )
}

public RestartRound()
{
	g_zombiescore = 0
	g_humanscore = 0
}