
//------------------------------------------------------------------------------
function serverCmdSetClientFav(%client, %text)
{
   if ( getWord( getField( %text, 0 ), 0 ) $= armor )
   {
      %client.curFavList = %text;
      %validList = checkInventory( %client, %text );
      %client.favorites[0] = getField( %text, 1 );
      %armor = getArmorDatablock( %client, $NameToInv[getField( %validList,1 )] );
      %weaponCount = 0;
      %packCount = 0;
      %grenadeCount = 0;
      %mineCount = 0;
      %count = 1;
      %client.weaponIndex = "";
      %client.packIndex = "";
      %client.grenadeIndex = "";
      %client.mineIndex = "";
      // HvC
      //
      %client.specialIndex = "";
      %specialCount = 0;
      
      for(%i = 3; %i < getFieldCount(%validList); %i = %i + 2)
      {
         %setItem = false;
         switch$ (getField(%validList,%i-1))
         {
            case weapon:
               if(%weaponCount < %armor.maxWeapons)
               {
                  if(!%weaponCount)
                     %client.weaponIndex = %count;
                  else
                     %client.weaponIndex = %client.weaponIndex TAB %count;
                  %weaponCount++;
                  %setItem = true;   
               }   
            case pack:
               if(%packCount < 1)
               {
                  %client.packIndex = %count;         
                  %packCount++;
                  %setItem = true;
               }
            case grenade:
               if(%grenadeCount < %armor.maxGrenades)
               {
                  if(!%grenadeCount)
                     %client.grenadeIndex = %count;
                  else
                     %client.grenadeIndex = %client.grenadeIndex TAB %count;
                  %grenadeCount++;
                  %setItem = true;   
               }  
            case mine:
               if(%mineCount < %armor.maxMines)
               {
                  if(!%mineCount)
                     %client.mineIndex = %count;
                  else
                     %client.mineIndex = %client.mineIndex TAB %count;
                  %mineCount++;
                  %setItem = true;   
               }  
            case special:
               if(%specialCount < 1)
               {
                  %client.specialIndex = %count;
                  %specialCount++;
                  %setItem = true;
               }
         }
         if(%setItem)
         {   
            %client.favorites[%count] = getField(%validList, %i);
            %count++;
         }
      }
      %client.numFavs = %count;
      %client.numFavsCount = 0;
      inventoryScreen::updateHud(1, %client, 'inventoryScreen');
   }
}


//------------------------------------------------------------------------------
function InventoryScreen::updateHud( %this, %client, %tag )
{
   %noSniperRifle = true;
   %armor = getArmorDatablock( %client, $NameToInv[%client.favorites[0]] );
   if ( %client.lastArmor !$= %armor )
   {
      %client.lastArmor = %armor;
      for ( %x = 0; %x < %client.lastNumFavs; %x++ )
         messageClient( %client, 'RemoveLineHud', "", 'inventoryScreen', %x );
      %setLastNum = true;
   }

   %cmt = $CurrentMissionType;
   
   //Create - ARMOR - List
   %armorList = %client.favorites[0];
   for ( %y = 0; $InvArmor[%y] !$= ""; %y++ )
      if ( $InvArmor[%y] !$= %client.favorites[0] )  
         %armorList = %armorList TAB $InvArmor[%y];

   //Create - WEAPON - List
   for ( %y = 0; $InvWeapon[%y] !$= ""; %y++ )
   {
      %notFound = true;
      for ( %i = 0; %i < getFieldCount( %client.weaponIndex ); %i++ )
      {
         %WInv = $NameToInv[$InvWeapon[%y]];
         if ( ( $InvWeapon[%y] $= %client.favorites[getField( %client.weaponIndex,%i )] ) || !%armor.max[%WInv] )  
         {
            %notFound = false;
            break;
         }
         else if ( "SniperRifle" $= $NameToInv[%client.favorites[getField( %client.weaponIndex,%i )]] )
         {
            %noSniperRifle = false;
            %packList = "noSelect\tEnergy Pack\tEnergy Pack must be used when \tLaser Rifle is selected!";     
            %client.favorites[getField(%client.packIndex,0)] = "Energy Pack";
         }   
      }

      if ( !($InvBanList[%cmt, %WInv]) )
      {
         if ( %notFound && %weaponList $= "" )
            %weaponList = $InvWeapon[%y];
         else if ( %notFound )
            %weaponList = %weaponList TAB $InvWeapon[%y];
      }
   }

   //Create - PACK - List
   if ( %noSniperRifle )
   {
      if ( getFieldCount( %client.packIndex ) )
         %packList = %client.favorites[getField( %client.packIndex, 0 )];
      else
      {
         %packList = "EMPTY";
         %client.numFavs++;
      }
      for ( %y = 0; $InvPack[%y] !$= ""; %y++ )
      {
         %PInv = $NameToInv[$InvPack[%y]];
         if ( ( $InvPack[%y] !$= %client.favorites[getField( %client.packIndex, 0 )]) && 
         %armor.max[%PInv] && !($InvBanList[%cmt, %PInv]))  
            %packList = %packList TAB $Invpack[%y];
      }
   }   
   
   //Create - GRENADE - List
   for ( %y = 0; $InvGrenade[%y] !$= ""; %y++ )
   {
      %notFound = true;
      for(%i = 0; %i < getFieldCount( %client.grenadeIndex ); %i++)
      {
         %GInv = $NameToInv[$InvGrenade[%y]];
         if ( ( $InvGrenade[%y] $= %client.favorites[getField( %client.grenadeIndex, %i )] ) || !%armor.max[%GInv] )  
         {
            %notFound = false;
            break;
         }
      }
      if ( !($InvBanList[%cmt, %GInv]) )
      { 
         if ( %notFound && %grenadeList $= "" )
            %grenadeList = $InvGrenade[%y];
         else if ( %notFound )
            %grenadeList = %grenadeList TAB $InvGrenade[%y];
      }
   }

   //HvC: Create - SPECIAL - List
   //
   if ( getFieldCount( %client.specialIndex ) )
      %specialList = %client.favorites[getField( %client.specialIndex, 0 )];
   else {
      %specialList = "EMPTY";
      %client.numFavs++;
   }
   for ( %y = 0; $InvSpecial[%y] !$= ""; %y++ ) {
      %SInv = $NameToInv[$InvSpecial[%y]];
      if ( $InvSpecial[%y] !$= %client.favorites[getField( %client.specialIndex, 0 )] && %armor.max[%SInv] && !$InvBanList[%cmt, %SInv] )  
         %specialList = %specialList TAB $InvSpecial[%y];
   }

   //Create - MINE - List
   for ( %y = 0; $InvMine[%y] !$= "" ; %y++ )
   {
      %notFound = true;
      %MInv = $NameToInv[$InvMine[%y]];
      for ( %i = 0; %i < getFieldCount( %client.mineIndex ); %i++ )
         if ( ( $InvMine[%y] $= %client.favorites[getField( %client.mineIndex, %i )] ) || !%armor.max[%MInv] )  
         {
            %notFound = false;
            break;
         }
      
      if ( !($InvBanList[%cmt, %MInv]) )
      {
         if ( %notFound && %mineList $= "" )
            %mineList = $InvMine[%y];
         else if ( %notFound )
            %mineList = %mineList TAB $InvMine[%y];
      }
   }

   %client.numFavsCount++;
   messageClient( %client, 'SetLineHud', "", %tag, 0, "Armor:", %armorList, armor, %client.numFavsCount );
   %lineCount = 1;

   // Weapons
   //
   for ( %x = 0; %x < %armor.maxWeapons; %x++ )
   {
      %client.numFavsCount++;
      if ( %x < getFieldCount( %client.weaponIndex ) )
      {
         %list = %client.favorites[getField( %client.weaponIndex,%x )];
         if ( %list $= Invalid )
         {
            %client.favorites[%client.numFavs] = "INVALID";
            %client.weaponIndex = %client.weaponIndex TAB %client.numFavs;
         }   
      }
      else
      {
         %list = "EMPTY";
         %client.favorites[%client.numFavs] = "EMPTY";
         %client.weaponIndex = %client.weaponIndex TAB %client.numFavs;
         %client.numFavs++;
      }
      if ( %list $= empty )
         %list = %list TAB %weaponList;
      else
         %list = %list TAB %weaponList TAB "EMPTY";
      messageClient( %client, 'SetLineHud', "", %tag, %x + %lineCount, "Weapon Slot " @ %x + 1 @ ": ", %list , weapon, %client.numFavsCount );
   }
   %lineCount = %lineCount + %armor.maxWeapons;

   // Pack
   //   
   %client.numFavsCount++;
   if ( getField( %packList, 0 ) !$= empty && %noSniperRifle )
      %packList = %packList TAB "EMPTY";
   %packText = %packList;
   %packOverFlow = "";
   %packOverFlow2 = "";
   if ( strlen( %packList ) > 255 )
   {
      %packText = getSubStr( %packList, 0, 255 );
      %packOverFlow = getSubStr( %packList, 255, 512 );
      if ( strlen( %packList ) > 255 )
      {
         %packOverFlow2 = getSubStr( %packList, 512, 766);
      }
   }
   messageClient( %client, 'SetLineHud', "", %tag, %lineCount, "Pack:", %packText, pack, %client.numFavsCount, %packOverFlow, %packOverFlow2 );
   %lineCount++;
   
   // Grenades
   //
   for( %x = 0; %x < %armor.maxGrenades; %x++ )
   {
      %client.numFavsCount++;
      if ( %x < getFieldCount( %client.grenadeIndex ) )
      {
         %list = %client.favorites[getField( %client.grenadeIndex, %x )];
         if (%list $= Invalid)
         {
            %client.favorites[%client.numFavs] = "INVALID";
            %client.grenadeIndex = %client.grenadeIndex TAB %client.numFavs;
         }
      }
      else
      {
         %list = "EMPTY";
         %client.favorites[%client.numFavs] = "EMPTY";
         %client.grenadeIndex = %client.grenadeIndex TAB %client.numFavs;
         %client.numFavs++;
      }
      
      if ( %list $= empty )
         %list = %list TAB %grenadeList;
      else
         %list = %list TAB %grenadeList TAB "EMPTY";

      messageClient( %client, 'SetLineHud', "", %tag, %x + %lineCount, "Grenade:", %list, grenade, %client.numFavsCount );
   }
   %lineCount = %lineCount + %armor.maxGrenades;

   // HvC: Specials
   //   
   %client.numFavsCount++;
   if ( getField( %specialList, 0 ) !$= empty )
      %specialList = %specialList TAB "EMPTY";
   %specialText = %specialList;
   %specialOverFlow = "";
   if ( strlen( %specialList ) > 255 )
   {
      %specialText = getSubStr( %specialList, 0, 255 );
      %specialOverFlow = getSubStr( %specialList, 255, 512 );
   }
   messageClient( %client, 'SetLineHud', "", %tag, %lineCount, "Special:", %specialText, special, %client.numFavsCount, %specialOverFlow );
   %lineCount++;

   // Mines
   //
   for ( %x = 0; %x < %armor.maxMines; %x++ )
   {
      %client.numFavsCount++;
      if ( %x < getFieldCount( %client.mineIndex ) )
      {
         %list = %client.favorites[getField( %client.mineIndex, %x )];
         if ( %list $= Invalid )
         {
            %client.favorites[%client.numFavs] = "INVALID";
            %client.mineIndex = %client.mineIndex TAB %client.numFavs;
         }
      }
      else
      {
         %list = "EMPTY";
         %client.favorites[%client.numFavs] = "EMPTY";
         %client.mineIndex = %client.mineIndex TAB %client.numFavs;
         %client.numFavs++;
      }
      
      if ( %list !$= Invalid )
      {
         if ( %list $= empty )
            %list = %list TAB %mineList;
         else if ( %mineList !$= "" )
            %list = %list TAB %mineList TAB "EMPTY";
         else 
            %list = %list TAB "EMPTY";
      }
         
      messageClient( %client, 'SetLineHud', "", %tag, %x + %lineCount, "Mine:", %list, mine, %client.numFavsCount );
   }

   if ( %setLastNum )
      %client.lastNumFavs = %client.numFavs;
}


//------------------------------------------------------------------------------
function buyFavorites(%client)
{
   // don't forget -- for many functions, anything done here also needs to be done
   // below in buyDeployableFavorites !!!
   %Player = %client.player;

   %Player.clearInventory();
   %client.setWeaponsHudClearAll();
   %cmt = $CurrentMissionType;

   %curArmor = %client.player.getDatablock();
   %curDmgPct = getDamagePercent(%curArmor.maxDamage, %Player.getDamageLevel());
   
   // armor
   %curArmor.unMountSpecialModel(%Client.player);
   %client.armor = $NameToInv[%client.favorites[0]];
   %Player.setArmor( %client.armor );
   %newArmor = %Player.getDataBlock();

   %Player.setDamageLevel(%curDmgPct * %newArmor.maxDamage);

   // special
   %pSp = $NameToInv[%client.favorites[%client.specialIndex]];
   if (%Client.player.getArmorSize() $= "Engineer" || %pSp $= "EngAssistant")
   {
      // Nothing here yet
   } else
      %Player.Special = %pSp;

   // weapons
   for(%i = 0; %i < getFieldCount( %client.weaponIndex ); %i++)
   {
      %inv = $NameToInv[%client.favorites[getField( %client.weaponIndex, %i )]];
      %Player.setInventory(%inv, 1);
      %AmmoName = %inv.image.ammo;
      %PlayerMax = %client.player.getDataBlock().max[%AmmoName];
      %Player.setInventory(%AmmoName, %PlayerMax * 2);

      if (%inv $= "Mortar" && %client.armor $= "Medium")
      {
         messageClient(%Client, '', "Weapons Control System purchased to control Mortar.");
         %client.Player.Special = "WCS";
      }
   }
   %client.player.weaponCount = getFieldCount( %client.weaponIndex );

   // pack
   %pCh = $NameToInv[%client.favorites[%client.packIndex]];
   if ( %pCh $= "" )
      %client.clearBackpackIcon();
   else
      %client.player.setInventory( %pCh, 1 );

   // if this pack is a deployable that has a team limit, warn the purchaser
	// if it's a deployable turret, the limit depends on the number of players (deployables.cs)
	if(%pCh $= "TurretIndoorDeployable" || %pCh $= "TurretOutdoorDeployable")
           %maxDep = countTurretsAllowed(%pCh);
	else
           // Barrels also fluctate
           if (%pCh.SmallTurretBarrel == true)
              %maxDep = countBarrelsAllowed(%pCh);
           else 
              %maxDep = $TeamDeployableMax[%pCh];

   if(%maxDep !$= "")
   {
      %depSoFar = $TeamDeployedCount[%client.team, %pCh];
      %packName = %client.favorites[%client.packIndex];

      if(Game.numTeams > 1)
         %msTxt = "Your team has " @ %depSoFar @ " of " @ %maxDep @ " " @ %packName @ "s deployed.";
      else
         %msTxt = "You have deployed " @ %depSoFar @ " of " @ %maxDep @ " " @ %packName @ "s.";

      messageClient(%client, 'MsgTeamDepObjCount', %msTxt);
   }

   // grenades
   for ( %i = 0; %i < getFieldCount( %client.grenadeIndex ); %i++ )
      %client.player.setInventory( $NameToInv[%client.favorites[getField( %client.grenadeIndex,%i )]], 30 );

   // if player is buying cameras, show how many are already deployed
   if(%client.favorites[%client.grenadeIndex] $= "Deployable Camera")
   {
      %maxDep = $TeamDeployableMax[DeployedCamera];
      %depSoFar = $TeamDeployedCount[%client.player.team, DeployedCamera];
      if(Game.numTeams > 1)
         %msTxt = "Your team has "@%depSoFar@" of "@%maxDep@" Deployable Cameras placed.";
      else
         %msTxt = "You have placed "@%depSoFar@" of "@%maxDep@" Deployable Cameras.";
      messageClient(%client, 'MsgTeamDepObjCount', %msTxt);
   }

   // mines
   for ( %i = 0; %i < getFieldCount( %client.mineIndex ); %i++ )
      %client.player.setInventory( $NameToInv[%client.favorites[getField( %client.mineIndex,%i )]], 30 );
         
   // miscellaneous stuff -- Repair Kit, Beacons, Targeting Laser
   if (!($InvBanList[%cmt, RepairKit]))
      %client.player.setInventory(RepairKit, 2);

   if (!($InvBanList[%cmt, Beacon]))
      %client.player.setInventory(Beacon, 400);

   if (!($InvBanList[%cmt, TargetingLaser]))
      %client.player.setInventory(TargetingLaser, 1);

   if (!($InvBanList[%cmt, FlashLight]))
      %client.player.setInventory(FlashLight, 1);

   // ammo pack pass
   if (%pCh $= "AmmoPack" )
      invAmmoPackPass(%client);

   if (%pCh $= "AutoRocketPack")
      %client.Player.inv[AutoRocketAmmo] = 6;

   if (%pCh $= "SMissilePack")
      %client.Player.inv[SMissileAmmo] = 2;

   %newArmor.mountSpecialModel(%Client.player);
   %Player.setImageTrigger($BackPackSlot, false);
   %Player.ShieldStrength = "";
   %Player.AutoRocketOn = "";
   %Player.ShoulderMissileMode = "";
   %Player.WCSProjectile = "";
   %Player.CantTeleport = "";
   %Player.PlayerNoFire = "";

   if (%Player.Hologram !$= "")
   {
      %Message = "Turning off Hologram.";
      messageClient(%Player.client, '', %Message);

      cancel(%Player.HologramMonitor);
      %Player.HologramMonitor = "";

      %Player.Hologram.setCloaked(true);
      %Player.Hologram.schedule(850, Delete);
      %Player.Hologram = "";
      return;
   }

   %Player.SetNewWeight();
}


//------------------------------------------------------------------------------
function createInvBanCount()
{
   $BanCount["Armor"] = 0;
   $BanCount["Weapon"] = 0;
   $BanCount["Pack"] = 0;
   $BanCount["Grenade"] = 0;
   $BanCount["Mine"] = 0;

   for(%i = 0; $InvArmor[%i] !$= ""; %i++)
      if($InvBanList[$CurrentMissionType, $NameToInv[$InvArmor[%i]]])
         $BanCount["Armor"]++;
   $InvTotalCount["Armor"] = %i;
   
   for(%i = 0; $InvWeapon[%i] !$= ""; %i++)
      if($InvBanList[$CurrentMissionType, $NameToInv[$InvWeapon[%i]]])
         $BanCount["Weapon"]++;
   $InvTotalCount["Weapon"] = %i;

   for(%i = 0; $InvPack[%i] !$= ""; %i++)
      if($InvBanList[$CurrentMissionType, $NameToInv[$InvPack[%i]]])
         $BanCount["Pack"]++;
   $InvTotalCount["Pack"] = %i;

   for(%i = 0; $InvGrenade[%i] !$= ""; %i++)
      if($InvBanList[$CurrentMissionType, $NameToInv[$InvGrenade[%i]]])
         $BanCount["Grenade"]++;
   $InvTotalCount["Grenade"] = %i;

   for(%i = 0; $InvMine[%i] !$= ""; %i++)
      if($InvBanList[$CurrentMissionType, $NameToInv[$InvMine[%i]]])
         $BanCount["Mine"]++;
   $InvTotalCount["Mine"] = %i;
   
  // HvC
  for(%i = 0; $InvSpecial[%i] !$= ""; %i++)
      if($InvBanList[$CurrentMissionType, $NameToInv[$InvSpecial[%i]]])
         $BanCount["special"]++;
   $InvTotalCount["special"] = %i;
}


//------------------------------------------------------------------------------
function buyDeployableFavorites(%client)
{
   %player = %client.player;
	%prevPack = %player.getMountedImage($BackpackSlot);
   %player.clearInventory();
   %client.setWeaponsHudClearAll();
   %cmt = $CurrentMissionType;

   %Armor = %Player.getDataBlock();

   %Armor.unMountSpecialModel(%Client.player);

   // Give player the special they chose
   %pSp = $NameToInv[%client.favorites[%client.specialIndex]];
   if (%Client.player.getArmorSize() $= "Engineer" || %pSp $= "EngAssistant")
   {
      // Nothing here yet
   } else
      %client.player.Special = %pSp;

   // weapons
   for(%i = 0; %i < getFieldCount( %client.weaponIndex ); %i++)
   {
      %inv = $NameToInv[%client.favorites[getField( %client.weaponIndex, %i )]];
      %client.player.setInventory(%inv, 1);
      %AmmoName = %inv.image.ammo;
      %PlayerMax = %client.player.getDataBlock().max[%AmmoName];
      %client.player.setInventory(%AmmoName, %PlayerMax * 2);

      if (%inv $= "Mortar" && %client.armor $= "Medium")
      {
         messageClient(%Client, '', "Weapons Control System purchased to control Mortar.");
         %client.Player.Special = "WCS";
      }
   }
   %client.player.weaponCount = getFieldCount( %client.weaponIndex );

   // give player the grenades they chose
   for ( %i = 0; %i < getFieldCount( %client.grenadeIndex ); %i++)
   {   
      %GInv = $NameToInv[%client.favorites[getField( %client.grenadeIndex, %i )]];
      if ( !($InvBanList[DeployInv, %GInv]) )
         %player.setInventory( %GInv, 30 );
   }

   // if player is buying cameras, show how many are already deployed
   if(%client.favorites[%client.grenadeIndex] $= "Deployable Camera")
   {
      %maxDep = $TeamDeployableMax[DeployedCamera];
      %depSoFar = $TeamDeployedCount[%client.player.team, DeployedCamera];
      if(Game.numTeams > 1)
         %msTxt = "Your team has "@%depSoFar@" of "@%maxDep@" Deployable Cameras placed.";
      else
         %msTxt = "You have placed "@%depSoFar@" of "@%maxDep@" Deployable Cameras.";
      messageClient(%client, 'MsgTeamDepObjCount', %msTxt);
   }

   // give player the mines they chose
   for ( %i = 0; %i < getFieldCount( %client.mineIndex ); %i++ )
   {
      %MInv = $NameToInv[%client.favorites[getField( %client.mineIndex, %i )]];
      if ( !($InvBanList[DeployInv, %MInv]) )
         %player.setInventory( %MInv, 30 );
   }
      
   if ( !($InvBanList[DeployInv, Beacon]) && !($InvBanList[%cmt, Beacon]) )
      %player.setInventory( Beacon, 400 );

   if ( !($InvBanList[DeployInv, RepairKit]) && !($InvBanList[%cmt, RepairKit]) )
      %player.setInventory( RepairKit, 1 );

   if ( !($InvBanList[DeployInv, TargetingLaser]) && !($InvBanList[%cmt, TargetingLaser]) )
      %player.setInventory(TargetingLaser, 1 );

   if ( !($InvBanList[DeployInv, FlashLight]) && !($InvBanList[%cmt, FlashLight]) )
      %player.setInventory(FlashLight, 1 );

   // players cannot buy deployable station packs from a deployable inventory station
   %packChoice = $NameToInv[%client.favorites[%client.packIndex]];
   if ( !($InvBanList[DeployInv, %packChoice]) )
      %player.setInventory( %packChoice, 1 );

   // if this pack is a deployable that has a team limit, warn the purchaser
	// if it's a deployable turret, the limit depends on the number of players (deployables.cs)
	if(%packChoice $= "TurretIndoorDeployable" || %packChoice $= "TurretOutdoorDeployable")
		%maxDep = countTurretsAllowed(%packChoice);
	else
	   %maxDep = $TeamDeployableMax[%packChoice];
   if((%maxDep !$= "") && (%packChoice !$= "InventoryDeployable"))
   {
      %depSoFar = $TeamDeployedCount[%client.player.team, %packChoice];
      %packName = %client.favorites[%client.packIndex];

      if(Game.numTeams > 1)
         %msTxt = "Your team has "@%depSoFar@" of "@%maxDep SPC %packName@"s deployed.";
      else
         %msTxt = "You have deployed "@%depSoFar@" of "@%maxDep SPC %packName@"s.";

      messageClient(%client, 'MsgTeamDepObjCount', %msTxt);
   }

	if(%prevPack > 0)
	{
		// if player had a "forbidden" pack (such as a deployable inventory station)
		// BEFORE visiting a deployed inventory station AND still has that pack chosen
		// as a favorite, give it back
		if((%packChoice $= %prevPack.item) && ($InvBanList[DeployInv, %packChoice]))
	      %player.setInventory( %prevPack.item, 1 );
	}

   if (%packChoice $= "AmmoPack")
      invAmmoPackPass(%client);

   if (%packChoice $= "AutoRocketPack")
      %client.Player.inv[AutoRocketAmmo] = 6;

   if (%packChoice $= "SMissilePack")
      %client.Player.inv[SMissileAmmo] = 2;

   %Armor.mountSpecialModel(%Client.player);
   %Player.setImageTrigger($BackPackSlot, false);
   %Player.ShieldStrength = "";
   %Player.AutoRocketOn = "";
   %Player.ShoulderMissileMode = "";
   %Player.WCSProjectile = "";
   %Player.CantTeleport = "";
   %Player.PlayerNoFire = "";
   %Player.cantAdrenaline = "";

   if (%Player.Hologram !$= "")
   {
      %Message = "Turning off Hologram.";
      messageClient(%Player.client, '', %Message);

      cancel(%Player.HologramMonitor);
      %Player.HologramMonitor = "";

      %Player.Hologram.setCloaked(true);
      %Player.Hologram.schedule(850, Delete);
      %Player.Hologram = "";
      return;
   }

   %Player.SetNewWeight();
}
