Note: An alternate menu hierarchy based System by Crashed can be found here.

---------------------------------------------------------------------------------------------------------------
VehiclePad Hud Page Cycling Tutorial
---------------------------------------------------------------------------------------------------------------
This tutorial is completely server side and allows you to fit more vehicles on the vehicle hud then the standard 6. It creates as many pages of up to 6 vehicles per page as needed, that people can cycle through by using the cycle weapon button when they're standing on the vehiclepad. It bottomprints a one time message to notify people the first time they get on a vehiclepad after logging on to the server.

Step #1
// ------------------------------------------
// Inventory.cs
// ------------------------------------------
This function handles the page cycling while on the vehiclepad. Change function serverCmdCycleWeapon( %client, %data ) to look like this:

function serverCmdCycleWeapon( %client, %data )
{
   if (%client.player.station)
   {
      if (%client.player.station.getDataBlock().getName() $= "StationVehicle")
         ChangeVehicleHud(%client);
   }
   %client.getControlObject().cycleWeapon( %data );
}


Step #2
// ------------------------------------------
// serverVehicleHud.cs
// ------------------------------------------

2a) Add this to the bottom of function VehicleHud::updateHud. (Note. leave only the first 6 vehicles in this function, don't add new vehicles here).

   %client.vehInvTag = %tag;
   %client.vehInvPage = 0;
   if (%client.usedVehHud != 1) //One time message to tell people to cycle pages
   {
      bottomPrint(%client, "Cycle Weapons to view more vehicles.", 3, 1);
      %client.usedVehHud = 1;
   }


2b) At the bottom of the serverVehicleHud.cs, add all this (There are two places that new vehicles need to be added in function ChangeVehicleHud. They're clearly marked, just add new vehicles the same as the vehicles right above them).


function ChangeVehicleHud(%client)
{
   %tag = %client.vehInvTag;
   %page = %client.vehInvPage;
   %count = %client.player.station.lastcount;
   clearHud( %client, %tag, %count );
   %station = %client.player.station;
   %team = %client.getSensorGroup();
   %count = 0;
   %i = 0;

   if ( %station.vehicle[scoutVehicle] )
   {
      %vehicleset[scoutVehicle] = %i;
      %i++;
   }
   if ( %station.vehicle[AssaultVehicle] )
   {
      %vehicleset[AssaultVehicle] = %i;
      %i++;
   }
   if ( %station.vehicle[mobileBaseVehicle] )
   {
      %vehicleset[mobileBaseVehicle] = %i;
      %i++;
   }
   if ( %station.vehicle[scoutFlyer] )
   {
      %vehicleset[scoutFlyer] = %i;
      %i++;
   }
   if ( %station.vehicle[bomberFlyer] )
   {
      %vehicleset[bomberFlyer] = %i;
      %i++;
   }
   if ( %station.vehicle[hapcFlyer] )
   {
      %vehicleset[hapcFlyer] = %i;
      %i++;
   }                                 //Add any custom vehicles after this one


                                     //End adding custom vehicles before here
   %totalpages = mCeil(%i / 6) - 1;
   %page++;
   if (%page > %totalpages)
      %page = 0;
   %initpos = (%page * 6);
   %endpos =  %initpos + 5;

   if ( checkVehSet(%vehicleset[scoutVehicle], %initpos) )
   {
      messageClient( %client, 'SetLineHud', "", %tag, %count, "GRAV CYCLE", "", ScoutVehicle, $VehicleMax[ScoutVehicle] - $VehicleTotalCount[%team, ScoutVehicle] );
      %count++;
   }
   if ( checkVehSet(%vehicleset[AssaultVehicle], %initpos) )
   {
      messageClient( %client, 'SetLineHud', "", %tag, %count, "ASSAULT TANK", "", AssaultVehicle, $VehicleMax[AssaultVehicle] - $VehicleTotalCount[%team, AssaultVehicle] );
      %count++;
   }
   if ( checkVehSet(%vehicleset[mobileBaseVehicle], %initpos) )
   {
      messageClient( %client, 'SetLineHud', "", %tag, %count, "MOBILE POINT BASE", "", MobileBaseVehicle, $VehicleMax[MobileBaseVehicle] - $VehicleTotalCount[%team, MobileBaseVehicle] );
      %count++;
   }
   if ( checkVehSet(%vehicleset[scoutFlyer], %initpos) )
   {
      messageClient( %client, 'SetLineHud', "", %tag, %count, "SCOUT FLIER", "", ScoutFlyer, $VehicleMax[ScoutFlyer] - $VehicleTotalCount[%team, ScoutFlyer] );
      %count++;
   }
   if ( checkVehSet(%vehicleset[bomberFlyer], %initpos) )
   {
      messageClient( %client, 'SetLineHud', "", %tag, %count, "BOMBER", "", BomberFlyer, $VehicleMax[BomberFlyer] - $VehicleTotalCount[%team, BomberFlyer] );
      %count++;
   }
   if ( checkVehSet(%vehicleset[hapcFlyer], %initpos) )
   {
      messageClient( %client, 'SetLineHud', "", %tag, %count, "TRANSPORT", "", HAPCFlyer, $VehicleMax[HAPCFlyer] - $VehicleTotalCount[%team, HAPCFlyer] );
      %count++;
   }
                           //Add any custom vehicles after this one


                          //End adding custom vehicles before here
   %station.lastCount = %count;
   %client.vehInvPage = %page;
}

function clearHud( %client, %tag, %count )
{
   for ( %i = 0; %i < %count; %i++ )
      messageClient( %client, 'RemoveLineHud', "", %tag, %i );
}

function checkVehSet(%obj, %initpos)
{
   if ((%obj !$= "") && (%obj >= %initpos) && (%obj <= (%initpos + 5)))
      return true;
   else
      return false;
}