------------------------------------------------------- ----------------Crashed's Vehicle Hud------------------ ------------------------------------------------------- ____________________________________ Original Code Created by: Crashed Code Fix by: BadShot Tutorial Revisted by: Drumstix42 ____________________________________ This tutorial has the code fix in it, so it's ready to use with new latest patches This tutorial will demonstrate how to create a vehicle station menu hierarchy which will allow you to have as many vehicles as you desire on your stations. This modification is entirely server side, NO client downloads are required. This is my first tutorial so please forgive any minor errors. ------------------------------------------------------------------------------------- All modifications are in serverVehicleHud.cs. _______________________________ ||||||||| STEP ONE |||||||||||| ------------------------------- Make the top of your serverCmdBuyVehicle() function look like this: Code: -------------------------------------------------------------------------------- function serverCmdBuyVehicle(%client, %blockName) { // NEW CODE BEGINS HERE // set a persistent variable to save what they selected %client.vehicleHudSelection = %blockName; // If they selected a submenu, // redir them to the submenu that is appropriate if( getSubStr(%blockName,0,3) $= "mnu" ) { //echo("got menu"); // they want a submenu - force the client to redisplay the hud commandToClient(%client, 'StationVehicleShowHud'); // done return; } // otherwise they are buying a vehicle // NEW CODE ENDS HERE %team = %client.getSensorGroup(); . . . -------------------------------------------------------------------------------- _______________________________ ||||||||| STEP TWO |||||||||||| ------------------------------- Replace the entire VehicleHud::updateHud() function with the following: Code: -------------------------------------------------------------------------------- // new vehicle menu code by Crashed function VehicleHud::updateHud( %obj, %client, %tag ) { %station = %client.player.station; for ( %i = 0; %i < 6; %i++ ) //Thanx BadShot messageClient( %client, 'RemoveLineHud', "", %tag, %i ); //Thanx BadShot %team = %client.getSensorGroup(); // if they don't have a menu default to main. %menu = %client.vehicleHudSelection; if($VehicleMenuNumEntries[%menu] < 1) %menu = "mnuMain"; // Print the menu. for( %i = 0; %i < $VehicleMenuNumEntries[%menu]; %i++ ) { %submenu = $VehicleMenu[%menu, %i, "submenu"]; %dbName = $VehicleMenu[%menu, %i, "datablock"]; %displayed = $VehicleMenu[%menu, %i, "displayed"]; // Set the availability count appropriately if(%submenu == true) %numAvail = 1; else if (%station.vehicle[%dbName]) %numAvail = $VehicleMax[%dbName] - $VehicleTotalCount[%team, %dbName]; else %numAvail = 0; //echo("sending to client i " @ %i @ " submenu " @ %submenu @ " dbname " @ %dbName @ " displayed " @ %displayed @ " numAvail " @ %numAvail); // Send update to client messageClient( %client, 'SetLineHud', "", %tag, %i, %displayed, "", %dbName, %numAvail ); } // Add a "return to main menu" option if we aren't there already if(%menu !$= "mnuMain") { messageClient( %client, 'SetLineHud', "", %tag, %i, "<-- Main Menu", "", mnuMain, 1); %station.lastCount = %i + 1; } else %station.lastCount = %i; // Reset the selection var %client.vehicleHudSelection = ""; // we're done return; } // end new code -------------------------------------------------------------------------------- _______________________________ ||||||||| STEP THREE |||||||||| ------------------------------- This is the part where we define what the menus will be. Place this code at the top of serverVehicleHud.cs. Each menu has a name which must begin with the letters mnu. The data associated with each menu is as follows: $VehicleMenuNumEntries[menuname] = the number of items on this menu. Then for each menu entry (zero-indexed) you must have: $VehicleMenu[menuname, index, "submenu"] = true/false depending on whether this menu entry will take you to a submenu. $VehicleMenu[menuname, index, "displayed"] = what should be displayed in the menu button $VehicleMenu[menuname, index, "datablock"] = the datablock that should be triggered. If you want to produce a submenu, this datablock must be a menu name (mnuSomething) Here is my menu setup code as an example: Code: -------------------------------------------------------------------------------- // bill - menu definitions // Each menu has a name beginning with mnu - this defines the number of entries $VehicleMenuNumEntries["mnuMain"] = 6; // mnuName, index, field = data // submenu - whether or not it is a submenu // datablock - the associated datablock // displayed - what should be displayed $VehicleMenu["mnuMain", 0, "submenu"] = true; $VehicleMenu["mnuMain", 0, "datablock"] = mnuLightFlyers; $VehicleMenu["mnuMain", 0, "displayed"] = "Light Flyers -->"; $VehicleMenu["mnuMain", 1, "submenu"] = true; $VehicleMenu["mnuMain", 1, "datablock"] = mnuAssaultFlyers; $VehicleMenu["mnuMain", 1, "displayed"] = "Assault Flyers -->"; $VehicleMenu["mnuMain", 2, "submenu"] = true; $VehicleMenu["mnuMain", 2, "datablock"] = mnuLightGround; $VehicleMenu["mnuMain", 2, "displayed"] = "Light Ground -->"; $VehicleMenu["mnuMain", 3, "submenu"] = true; $VehicleMenu["mnuMain", 3, "datablock"] = mnuHeavyGround; $VehicleMenu["mnuMain", 3, "displayed"] = "Heavy Ground -->"; $VehicleMenu["mnuMain", 4, "submenu"] = true; $VehicleMenu["mnuMain", 4, "datablock"] = mnuTransports; $VehicleMenu["mnuMain", 4, "displayed"] = "Transports -->"; $VehicleMenu["mnuMain", 5, "submenu"] = true; $VehicleMenu["mnuMain", 5, "datablock"] = mnuDeployables; $VehicleMenu["mnuMain", 5, "displayed"] = "Deployables -->"; // Light Flyers menu $VehicleMenuNumEntries["mnuLightFlyers"] = 1; $VehicleMenu["mnuLightFlyers", 0, "submenu"] = false; $VehicleMenu["mnuLightFlyers", 0, "datablock"] = ScoutFlyer; $VehicleMenu["mnuLightFlyers", 0, "displayed"] = "Shrike Light Fighter"; // Assault Flyers menu $VehicleMenuNumEntries["mnuAssaultFlyers"] = 1; $VehicleMenu["mnuAssaultFlyers", 0, "submenu"] = false; $VehicleMenu["mnuAssaultFlyers", 0, "datablock"] = BomberFlyer; $VehicleMenu["mnuAssaultFlyers", 0, "displayed"] = "Thundersword Bomber"; // Light Ground menu $VehicleMenuNumEntries["mnuLightGround"] = 1; $VehicleMenu["mnuLightGround", 0, "submenu"] = false; $VehicleMenu["mnuLightGround", 0, "datablock"] = ScoutVehicle; $VehicleMenu["mnuLightGround", 0, "displayed"] = "Wildcat Hoverbike"; // Heavy Ground menu $VehicleMenuNumEntries["mnuHeavyGround"] = 1; $VehicleMenu["mnuHeavyGround", 0, "submenu"] = false; $VehicleMenu["mnuHeavyGround", 0, "datablock"] = AssaultVehicle; $VehicleMenu["mnuHeavyGround", 0, "displayed"] = "Beowulf Assault Tank"; // Transports menu $VehicleMenuNumEntries["mnuTransports"] = 1; $VehicleMenu["mnuTransports", 0, "submenu"] = false; $VehicleMenu["mnuTransports", 0, "datablock"] = HAPCFlyer; $VehicleMenu["mnuTransports", 0, "displayed"] = "Havoc Aerial APC"; //Deployables menu $VehicleMenuNumEntries["mnuDeployables"] = 1; $VehicleMenu["mnuDeployables", 0, "submenu"] = false; $VehicleMenu["mnuDeployables", 0, "datablock"] = MobileBaseVehicle; $VehicleMenu["mnuDeployables", 0, "displayed"] = "Jericho Mobile Base"; -------------------------------------------------------------------------------- Note: The menu that comes up when someone first steps on the station is mnuMain. Good luck! Crashed. -------------------------------------------------- Also Thanx to BadShot for helping to fix the code. --------------------------------------------------