
cleanallhud()
{
	if(isDefined(level.clock)) level.clock destroy();
	if(isDefined(level.wwx_axisicon)) level.wwx_axisicon destroy();
	if(isDefined(level.wwx_axisnumber)) level.wwx_axisnumber destroy();
	if(isDefined(level.wwx_deadaxisicon)) level.wwx_deadaxisicon destroy();
	if(isDefined(level.wwx_deadaxisnumber)) level.wwx_deadaxisnumber destroy();
	if(isDefined(level.wwx_alliedicon)) level.wwx_alliedicon destroy();
	if(isDefined(level.wwx_alliednumber)) level.wwx_alliednumber destroy();
	if(isDefined(level.wwx_deadalliedicon)) level.wwx_deadalliedicon destroy();
	if(isDefined(level.wwx_deadalliednumber)) level.wwx_deadalliednumber destroy();
	if(isDefined(level.wwx_gtsmsg)) level.wwx_gtsmsg destroy();
      if(isDefined(level.wwx_mapannouncer)) level.wwx_mapannouncer destroy();
	if(level.wwx_ranksystem)
	{
		if(isdefined(self.wwx_rankhud0) ) self.wwx_rankhud0 destroy();
		if(isdefined(self.wwx_rankhud1) ) self.wwx_rankhud1 destroy();
		if(isdefined(self.wwx_rankhud2) ) self.wwx_rankhud2 destroy();
	}

	// fade out modinfo, move to centre and fade in
	if(isDefined(level.wwx_modinfo))
	{
		level.wwx_modinfo fadeOverTime(1);
		level.wwx_modinfo.alpha = 0;
		wait 1;
		level.wwx_modinfo.x = 320;
		level.wwx_modinfo.alignX = "center";
		level.wwx_modinfo fadeOverTime(1);
		level.wwx_modinfo.alpha = 0.8;
		wait 1;
	}
}

cleanplayerend()
{
	maps\mp\gametypes\_hud_teamscore::removePlayerHUD();
	maps\mp\gametypes\_hud_playerscore::removePlayerHUD();

	if(isdefined(self.wwx_parachute)) self.wwx_parachute destroy();
	if(isdefined(self.wwx_anchor)) self.wwx_anchor destroy();

}

cleanplayer()
{
	[[level.wwx_clearlnb]]("self",5);

	if(isDefined(self.wwx_sintimer)) self.wwx_sintimer destroy();
	if(isDefined(self.wwx_sintimertxt)) self.wwx_sintimertxt destroy();
	if(isDefined(self.wwx_laserdot)) self.wwx_laserdot destroy();
	if(isDefined(self.wwx_sprinthud)) self.wwx_sprinthud destroy();
	if(isDefined(self.wwx_sprinthud_back)) self.wwx_sprinthud_back destroy();
	if(isDefined(self.wwx_sprinthud_hint)) self.wwx_sprinthud_hint destroy();
	if(isDefined(self.wwx_sintimer)) self.wwx_sintimer destroy();
	if(isDefined(self.wwx_sintimertxt)) self.wwx_sintimertxt destroy();
	if(isDefined(self.wwx_laserdot)) self.wwx_laserdot destroy();
	if(isDefined(self.wwx_firstaidicon)) self.wwx_firstaidicon destroy();
	if(isDefined(self.wwx_firstaidtxt)) self.wwx_firstaidtxt destroy();
	if(isDefined(self.wwx_firstaidval)) self.wwx_firstaidval destroy();
	if(isDefined(self.wwx_rankhud)) self.wwx_rankhud destroy();
	if(isDefined(self.mortar_available_icon)) self.mortar_available_icon destroy();
	if(isDefined(self.artillery_available_icon)) self.artillery_available_icon destroy();
	if(isDefined(self.airstrike_available_icon)) self.airstrike_available_icon destroy();
	if(isDefined(self.wwx_binocular_hint)) self.wwx_binocular_hint destroy();
	if(isdefined(self.wwx_parachute)) self.wwx_parachute delete();
	if(isdefined(self.wwx_anchor)) self.wwx_anchor delete();
      if(isDefined(self.wwx_sptimer)) self.wwx_sptimer destroy();
      if(isDefined(self.wwx_mapannouncer)) self.wwx_mapannouncer destroy();

	if(isDefined(self.mine_hud_icon)) self.mine_hud_icon destroy();
	if(isDefined(self.mine_hud_ammo)) self.mine_hud_ammo destroy();
	if(isDefined(self.mine_hud_warn)) self.mine_hud_warn destroy();
	if(isDefined(self.mine_hud_defuse)) self.mine_hud_defuse destroy();
	if(isDefined(self.mine_hud_plant)) self.mine_hud_plant destroy();
	if(isDefined(self.mine_hud_progress_bg)) self.mine_hud_progress_bg destroy();
	if(isDefined(self.mine_hud_progress)) self.mine_hud_progress destroy();
        if(isDefined(self.wwx_spwpro)) self.wwx_spwpro destroy();
	if(isDefined(self.wwx_bloodonscreen)) self.wwx_bloodonscreen destroy();
	if(isDefined(self.wwx_bloodonscreen1)) self.wwx_bloodonscreen1 destroy();
	if(isDefined(self.wwx_bloodonscreen2)) self.wwx_bloodonscreen2 destroy();
	if(isDefined(self.wwx_bloodonscreen3)) self.wwx_bloodonscreen3 destroy();

	if(isDefined(self.wwx_wwxpmsg1)) self.wwx_wwxpmsg1 destroy();
	if(isDefined(self.wwx_wwxpmsg2)) self.wwx_wwxpmsg2 destroy();
	if(isDefined(self.wwx_wwxpmsg3)) self.wwx_wwxpmsg3 destroy();

	if(isdefined(self.wwx_overheatbarbackground))	self.wwx_overheatbarbackground destroy();
	if(isdefined(self.wwx_overheatbar))			self.wwx_overheatbar destroy();
	if(isdefined(self.wwx_overheatmessage))		self.wwx_overheatmessage destroy();
	if(isdefined(self.turret_pointer)) self.turret_pointer destroy();

	if(isDefined(self.wwx_pbbgrd)) self.wwx_pbbgrd destroy();
	if(isDefined(self.wwx_pb)) self.wwx_pb destroy();
	if(isDefined(self.wwx_actimer)) self.wwx_actimer destroy();
	if(isDefined(self.wwx_tripwarning)) self.wwx_tripwarning destroy();

	if(level.wwx_ranksystem)
	{
		if(isdefined(self.wwx_rankhud0) ) self.wwx_rankhud0 destroy();
		if(isdefined(self.wwx_rankhud1) ) self.wwx_rankhud1 destroy();
		if(isdefined(self.wwx_rankhud2) ) self.wwx_rankhud2 destroy();
	}

	if(isDefined(self.wwx_bleedmsg)) self.wwx_bleedmsg destroy();
	if(isDefined(self.wwx_roundnumber)) self.wwx_roundnumber destroy();

	if(level.wwx_bulletholes && isDefined(self.wwx_bulletholes))
	{
		for(i = 0; i < self.wwx_bulletholes.size; i++)
		{
			if(isDefined(self.wwx_bulletholes[i])) self.wwx_bulletholes[i] destroy();
		}
	}

	if(isDefined(self.wwx_healthbar)) self.wwx_healthbar destroy();
	if(isDefined(self.wwx_healthback)) self.wwx_healthback destroy();
	if(isDefined(self.wwx_healthcross)) self.wwx_healthcross destroy();

	if(isDefined(self.wwx_srvlogoback)) self.wwx_srvlogoback destroy();
	if(isDefined(self.wwx_srvlogofront)) self.wwx_srvlogofront destroy();

	if(isDefined(self.wwx_headmarker))
	{
		self.wwx_headmarker stoploopsound();
		self.wwx_sprintreco = false;
		self.wwx_headmarker unlink();
		self.wwx_headmarker delete();
	}

	if(isDefined(self.wwx_spinemarker))
	{
		self.wwx_spinemarker unlink();
		self.wwx_spinemarker delete();
	}

       if(isDefined(self.wwx_eyemarker))
       {
        self.wwx_eyemarker unlink();
        self.wwx_eyemarker delete();
       }
       
       if(isDefined(level.wwx_rangehud)) self.wwx_rangehud destroy();

/*
	if(isDefined(self.wwx_elbowmark))
	{
		self.wwx_elbowmarker unlink();
		self.wwx_elbowmarker delete();
	}

	if(isDefined(self.wwx_eyemarker))
	{
		self.wwx_eyemarker unlink();
		self.wwx_eyemarker delete();
	}

	if(isDefined(self.wwx_thumbmarker))
	{
		self.wwx_thumbmarker unlink();
		self.wwx_thumbmarker delete();
	}
*/	
}

movieMode()
{
	level endon("wwx_gameover");
	self endon("disconnect");

	if(isDefined(self.wwx_letterboxtop)) while(isPlayer(self) && isDefined(self.wwx_letterboxtop)) wait 0.05;

	wait 0.05;

	if(isPlayer(self))
	{
		self.wwx_letterboxtop = newClientHudElem(self);
		self.wwx_letterboxtop.alignX = "left";
		self.wwx_letterboxtop.alignY = "top";
		self.wwx_letterboxtop.x = 0;
		self.wwx_letterboxtop.sort = - 50;
		self.wwx_letterboxtop.alpha = 0;
		self.wwx_letterboxtop setShader("black", 640, 80);
	
		self.wwx_letterboxbottom = newClientHudElem(self);
		self.wwx_letterboxbottom.alignX = "left";
		self.wwx_letterboxbottom.alignY = "top";
		self.wwx_letterboxbottom.x = 0;
		self.wwx_letterboxbottom.sort = - 50;
		self.wwx_letterboxbottom.alpha = 0;
		self.wwx_letterboxbottom setShader("black", 640, 80);
	
		self.wwx_letterboxtop fadeOverTime(4);
		self.wwx_letterboxtop.alpha = 1;
		self.wwx_letterboxbottom fadeOverTime(4);
		self.wwx_letterboxbottom.alpha = 1;
	
		for(i = 0; i < 80; i++)
		{
			if(isDefined(self.wwx_letterboxtop)) self.wwx_letterboxtop.y = -80 + i;
			if(isDefined(self.wwx_letterboxtop)) self.wwx_letterboxbottom.y = 480 - i;
			wait 0.02;
		}
	}
}

movieRemove()
{
	level endon("wwx_gameover");
	self endon("disconnect");

	if(!level.wwx_forcespawn)
	{
		if(isDefined(self.wwx_letterboxtop))
		{
			self.wwx_letterboxtop fadeOverTime(4);
			self.wwx_letterboxtop.alpha = 0;
		}

		if(isDefined(self.wwx_letterboxbottom))
		{
			self.wwx_letterboxbottom fadeOverTime(4);
			self.wwx_letterboxbottom.alpha = 0;
		}

		for(i = 0; i < 80; i++)
		{
			if(isDefined(self.wwx_letterboxtop)) self.wwx_letterboxtop.y = 0 - i;
			if(isDefined(self.wwx_letterboxtop)) self.wwx_letterboxbottom.y = 400 + i;

			wait 0.02;
		}

		if(isDefined(self.wwx_letterboxtop)) self.wwx_letterboxtop destroy();
		if(isDefined(self.wwx_letterboxbottom)) self.wwx_letterboxbottom destroy();
	}
}