DoPrecache()
{

	
	// String Precache
	precacheString(&"^7Total Kills:^9");
	precacheString(&"^7Total Headshots:^9");
	precacheString(&"^7Total Bashes:^9");
	precacheString(&"^7Current Headshots:^9");
	precacheString(&"^7Current Bashes:^9");
}

OnPlayerConnected()
{
	self thread OnPlayerHasSpawned();
	self thread onJoinedTeam();
	self thread onJoinedSpectators();
}

OnPlayerHasSpawned()
{
//	level endon("end_map");
//	self endon("disconnect");

	for(;;)
	{
		self waittill("spawned_player");
		self.spamdelay = undefined;
		self notify("end_admin_check");
		waittillframeend;

		if(!isDefined(self.showedHead))
			self thread ShowHead();

		if(!isDefined(self.showedBash))
			self thread ShowBash();
			
		if(isDefined(self.hudHeadText))
			self.hudHeadText.alpha = 1;
	
		if(isDefined(self.hudHead))
			self.hudHead.alpha = 1;
	
		if(!isDefined(self.showedKills))
			self thread ShowKills();

		if(!isDefined(self.showcurrentHead))
			self thread ShowCurrentHead();

		if(!isDefined(self.showcurrentBash))
			self thread ShowCurrentBash();


			
	}
}


onJoinedTeam()
{
//    self endon("disconnect");
    
    for(;;)
    {
		self waittill("joined_team");
		self thread ShowHead();
		self thread ShowBash();
		self thread ShowKills();
		self thread ShowCurrentHead();
		self thread ShowCurrentBash();
    }
}

onJoinedSpectators()
{
//    self endon("disconnect");
    
    for(;;)
    {
		self waittill("joined_spectators");	
		

		if(isDefined(self.hudHeadText))
			self.hudHeadText destroy();
	
		if(isDefined(self.hudHead))
			self.hudHead destroy();

		if(isDefined(self.hudBashText))
			self.hudBashText destroy();
	
		if(isDefined(self.hudBash))
			self.hudBash destroy();

		if(isDefined(self.hudKillsText))
			self.hudKillsText destroy();
	
		if(isDefined(self.hudKills))
			self.hudKills destroy();

		if(isDefined(self.hudCurrentHeadText))
			self.hudCurrentHeadText destroy();
	
		if(isDefined(self.hudCurrentHead))
			self.hudCurrentHead destroy();

		if(isDefined(self.hudCurrentBashText))
			self.hudCurrentBashText destroy();
	
		if(isDefined(self.hudCurrentBash))
			self.hudCurrentBash destroy();
		
    }
}

showHead()
{
	if(!isDefined(self.pers["totalHead"]))
		self.pers["totalHead"] = 0;
		
	if(!isDefined(self.hudHeadText))
	{
		self.hudHeadText = newClientHudElem(self);
 		self.hudHeadText.x = 550;
 		self.hudHeadText.y = 240;
		self.hudHeadText.alignX = "center";
 		self.hudHeadText.alignY = "middle";	
		self.hudHeadText.sort = 99;
		self.hudHeadText setText(&"^7Total Headshots:^9");
	}
	
	if(!isDefined(self.hudHead))
	{
		self.hudHead = newClientHudElem(self);
 		self.hudHead.x = 610;
 		self.hudHead.y = 240;
		self.hudHead.alignX = "center";
 		self.hudHead.alignY = "middle";	
		self.hudHead.sort = 99;
		self.hudHead setValue(self.pers["totalHead"]);
	}
	self.showedHead = true;
}

updateHead()
{
	if(isDefined(self.hudHead))
	{
		self.hudHead.alpha = 1;
		self.hudHead setValue(self.pers["totalHead"]);
	}
}

showBash()
{
	if(!isDefined(self.pers["totalBash"]))
		self.pers["totalBash"] = 0;
		
	if(!isDefined(self.hudBashText))
	{
		self.hudBashText = newClientHudElem(self);
 		self.hudBashText.x = 550;
 		self.hudBashText.y = 260;
		self.hudBashText.alignX = "center";
 		self.hudBashText.alignY = "middle";	
		self.hudBashText.sort = 99;
		self.hudBashText setText(&"^7Total Bashes:^9");
	}
	
	if(!isDefined(self.hudBash))
	{
		self.hudBash = newClientHudElem(self);
 		self.hudBash.x = 610;
 		self.hudBash.y = 260;
		self.hudBash.alignX = "center";
 		self.hudBash.alignY = "middle";	
		self.hudBash.sort = 99;
		self.hudBash setValue(self.pers["totalBash"]);
	}
	self.showedBash = true;
}

updateBash()
{
	if(isDefined(self.hudBash))
	{
		self.hudBash.alpha = 1;
		self.hudBash setValue(self.pers["totalBash"]);
	}
}

showKills()
{

	if(!isDefined(self.pers["totalKills"]))
		self.pers["totalKills"] = 0;
		
	if(!isDefined(self.hudKillsText))
	{
		self.hudKillsText = newClientHudElem(self);
 		self.hudKillsText.x = 550;
 		self.hudKillsText.y = 220;
		self.hudKillsText.alignX = "center";
 		self.hudKillsText.alignY = "middle";	
		self.hudKillsText.sort = 99;
		self.hudKillsText setText(&"^7Total Kills:^9");
	}
	
	if(!isDefined(self.hudKills))
	{
		self.hudKills = newClientHudElem(self);
 		self.hudKills.x = 610;
 		self.hudKills.y = 220;
		self.hudKills.alignX = "center";
 		self.hudKills.alignY = "middle";	
		self.hudKills.sort = 99;
		self.hudKills setValue(self.pers["totalKills"]);
	}
	self.showedKills = true;
}

updateKills()
{
	if(isDefined(self.hudKills))
	{
		self.hudKills.alpha = 1;
		self.hudKills setValue(self.pers["totalKills"]);
	}
}

showCurrentHead()
{
	if(!isDefined(self.pers["CurrentHead"]))
		self.pers["CurrentHead"] = 0;
		
	if(!isDefined(self.hudCurrentHeadText))
	{
		self.hudCurrentHeadText = newClientHudElem(self);
 		self.hudCurrentHeadText.x = 550;
 		self.hudCurrentHeadText.y = 280;
		self.hudCurrentHeadText.alignX = "center";
 		self.hudCurrentHeadText.alignY = "middle";	
		self.hudCurrentHeadText.sort = 99;
		self.hudCurrentHeadText setText(&"^7Current Headshots:^9");
	}
	
	if(!isDefined(self.hudCurrentHead))
	{
		self.hudCurrentHead = newClientHudElem(self);
 		self.hudCurrentHead.x = 610;
 		self.hudCurrentHead.y = 280;
		self.hudCurrentHead.alignX = "center";
 		self.hudCurrentHead.alignY = "middle";	
		self.hudCurrentHead.sort = 99;
		self.hudCurrentHead setValue(self.pers["CurrentHead"]);
	}
	self.showCurrentHead = true;
}

updateCurrentHead()
{
	if(isDefined(self.hudCurrentHead))
	{
		self.hudCurrentHead.alpha = 1;
		self.hudCurrentHead setValue(self.pers["CurrentHead"]);
	}
}

showCurrentBash()
{
	if(!isDefined(self.pers["CurrentBash"]))
		self.pers["CurrentBash"] = 0;
		
	if(!isDefined(self.hudCurrentBashText))
	{
		self.hudCurrentBashText = newClientHudElem(self);
 		self.hudCurrentBashText.x = 550;
 		self.hudCurrentBashText.y = 300;
		self.hudCurrentBashText.alignX = "center";
 		self.hudCurrentBashText.alignY = "middle";	
		self.hudCurrentBashText.sort = 99;
		self.hudCurrentBashText setText(&"^7Current Bashes:^9");
	}
	
	if(!isDefined(self.hudCurrentBash))
	{
		self.hudCurrentBash = newClientHudElem(self);
 		self.hudCurrentBash.x = 610;
 		self.hudCurrentBash.y = 300;
		self.hudCurrentBash.alignX = "center";
 		self.hudCurrentBash.alignY = "middle";	
		self.hudCurrentBash.sort = 99;
		self.hudCurrentBash setValue(self.pers["CurrentBash"]);
	}
	self.showCurrentBash = true;
}

updateCurrentBash()
{
	if(isDefined(self.hudCurrentBash))
	{
		self.hudCurrentBash.alpha = 1;
		self.hudCurrentBash setValue(self.pers["CurrentBash"]);
	}
}