Init()
{
	//Players Left Display
	if (level.gametype != "dm" || level.gametype != "tdm")
		Players_Left_Init();
}

Players_Left_Init()
{
	if(getCvar("scr_show_playersleft") == "")
		setCvar("scr_show_playersleft", "1");
	level.playersleftHUD = getCvarInt("scr_show_playersleft");

	// PRECACHE!
	// Players Left
	game["axis_hud_text"] = &"^7Axis:";
	precacheString(game["axis_hud_text"]);
	game["allies_hud_text"] = &"^7Allies:";
	precacheString(game["allies_hud_text"]);

	if (level.playersleftHUD)
		thread Do_Players_Left_HUD();
}

Do_Players_Left_HUD()
{
	axisleftnum = newHudElem();
	axisleftnum.x = 300;
	axisleftnum.y = 20;
	axisleftnum.alignX = "right";
	axisleftnum.alignY = "bottom";
	axisleftnum.fontScale = 1.1;
	axisleftnum.color = (1, 1, 1);
	axisleftnum.alpha = 1;

	axisleft = newHudElem();
	axisleft.x = 240;
	axisleft.y = 20;
	axisleft.alignX = "left";
	axisleft.alignY = "bottom";
	axisleft.fontScale = 1.1;
	axisleft.color = (1, 1, 1);
	axisleft.alpha = 1;
	axisleft setText(game["axis_hud_text"]);

	alliesleftnum = newHudElem();
	alliesleftnum.x = 374;
	alliesleftnum.y = 20;
	alliesleftnum.alignX = "right";
	alliesleftnum.alignY = "bottom";
	alliesleftnum.fontScale = 1.1;
	alliesleftnum.color = (1, 1, 1);
	alliesleftnum.alpha = 1;

	alliesleft = newHudElem();
	alliesleft.x = 310;
	alliesleft.y = 20;
	alliesleft.alignX = "left";
	alliesleft.alignY = "bottom";
	alliesleft.fontScale = 1.1;
	alliesleft.color = (1, 1, 1);
	alliesleft.alpha = 1;
	alliesleft setText(game["allies_hud_text"]);


	while (level.playersleftHUD)
	{
		wait .3;

		allied_alive = 0;
		axis_alive = 0;
		
		players = getentarray("player", "classname");
		for(i = 0; i < players.size; i++)
		{
			player = players[i];
			
			if(isDefined(player.pers["team"]) && player.pers["team"] != "spectator" && player.sessionstate == "playing")
			{

				if(player.pers["team"] == "allies")
					allied_alive++;
				else if(player.pers["team"] == "axis")
					axis_alive++;
			}
		}

		if (allied_alive < 2)
		{
			alliesleftnum.color = (.99, .63, .63);
			alliesleft.color = (.99, .63, .63);
		}
		else
		{
			alliesleftnum.color = (.85, .99, .99);
			alliesleft.color = (.85, .99, .99);
		}

		if (axis_alive < 2)
		{
			axisleftnum.color = (.99, .63, .63);
			axisleft.color = (.99, .63, .63);
		}
		else
		{
			axisleftnum.color = (.73, .99, .75);
			axisleft.color = (.73, .99, .75);
		}
				
		alliesleftnum setValue(allied_alive);
		axisleftnum setValue(axis_alive);
	}

	if(isdefined(alliesleft))
		alliesleft destroy();
	if(isdefined(axisleft))
		axisleft destroy();
	if(isdefined(alliesleftnum))
		alliesleftnum destroy();
	if(isdefined(axisleftnum))
		axisleftnum destroy();
}