in the server/scripts/ folder: 

Edit weapon.cs:

change the following line in the weapon::onUse function:

 	messageClient(%obj.client, 'MsgWeaponUsed', '\c0Weapon selected');

to:
 	
 	messageClient(%obj.client, 'MsgWeaponUsed', '\c0Weapon selected',%data);
 	

Edit player.cs add the following to the PlayerData datablock:

  maxInv[CrossbowAmmo1] = 50;
  maxInv[CrossbowAmmo2] = 50;
  maxInv[CrossbowAmmo3] = 50;
  
  
Edit item.cs in Item::onPickup replace the following line:

	%user.incInventory(%this,%count);
	
with this:
	
 	if (%this.className $= "Ammo") {
 		%weapon = %user.getMountedImage(0);
 		%user.incInventory($ammo[ %weapon.item, %user.cycleId[ %weapon.item ] ] ,%count);
  		%user.incInventory(%this,%count);
   }
 	else {
    	%user.incInventory(%this,%count);
   }
   
   
Edit inventory.cs add this line, in the shapebase::setInventory function:

	messageClient(%this.client,'MsgInventory',"",%data.className,%data,%value);

before this line:

// Set the inventory amount for this datablock and invoke	


edit game.cs in the GameConnection::onDeath after the following lines: 

	// Clear out the name on the corpse
   %this.player.setShapeName("");

add this:   

	messageClient(%this,'MsgPlayerDied',"");
	
at the end of GameConnection::createPlayer add the following lines:

	%player.setInventory(Crossbow,1); 
   %player.setInventory(CrossbowAmmo1,20); 
   %player.setInventory(CrossbowAmmo2,20); 
   %player.setInventory(CrossbowAmmo3,20);
   %player.setInventory(CrossbowAmmo,20);
   %player.use(Crossbow);
   
   
Edit crossbow.cs replace the following lines in CrossbowImage::onFire:
   
   %projectile = %this.projectile;

   // Decrement inventory ammo. The image's ammo state is update
   // automatically by the ammo inventory hooks.
   %obj.decInventory(%this.ammo,1);
	
with this:

  	%ammo=%obj.ammo[ %this.item ];
 	%projectile = %obj.projectile[%this.item];
    	
   // Decrement inventory ammo. The image's ammo state is update
   // automatically by the ammo inventory hooks.
 
  	%obj.decInventory(%ammo,1);
 	%obj.decInventory(%this.ammo,1);
 	
At the end of crossbow.cs add the following:

 $projectile["crossbow",1] = CrossbowProjectile;
 $projectile["crossbow",2] = CrossbowProjectile2;
 $projectile["crossbow",3] = CrossbowProjectile3;
 
 $ammo["crossbow",0] = CrossbowAmmo;
 $ammo["crossbow",1] = CrossbowAmmo1;
 $ammo["crossbow",2] = CrossbowAmmo2;
 $ammo["crossbow",3] = CrossbowAmmo3;
 
 
 function CrossbowImage::onMount(%this,%obj,%slot)
 {
    // Images assume a false ammo state on load.  We need to
    // set the state according to the current inventory.
 
    if (!%obj.cycleId[%this.item]) {
 		%obj.projectile[%this.item] = $projectile[%this.item,1];
 		%obj.ammo[%this.item] = $ammo[%this.item,1];
 		%obj.cycleId[%this.item] = 1;
 	}   
    
    %obj.setInventory( $ammo[%weapon.item,0] , %obj.getInventory( $ammo[ %weapon.item, %obj.cycleId[ %weapon.item ] ] ) );
    
    if (%obj.getInventory(%this.ammo))
       %obj.setImageAmmo(%slot,true);
 }
 
 function serverCmdchangeammo(%client)
 {
 	%weapon = %client.player.getMountedImage(0);
 	%client.player.cycleId[%weapon.item] = %client.player.cycleId[%weapon.item]+1;
 	if (%client.player.cycleId[%weapon.item] > 3) {
 		%client.player.cycleId[%weapon.item] = 1;
 	}
 	%client.player.setInventory( $ammo[%weapon.item,0] , %client.player.getInventory( $ammo[ %weapon.item, %client.player.cycleId[ %weapon.item ] ] ) );
 	%client.player.projectile[%weapon.item] = $projectile[%weapon.item,%client.player.cycleId[%weapon.item]];
 	%client.player.ammo[%weapon.item] = $ammo[%weapon.item,%client.player.cycleId[%weapon.item]];			
 	messageClient(%client,'MsgAmmoChange',"",%client.player.ammo[%weapon.item]);  
 }
 
You will also need to create 3 new ammo definitions and 3 new projectile definitions (see samle file)
 

Next you will need to add a new file in the client/scripts/ folder named inventory.cs

    addMessageCallback('MsgAmmoChange', handleAmmoChange);
    addMessageCallback('MsgWeaponUsed', handleWeaponUsed);
    addMessageCallback('MsgInventory', handleInventory);
    addMessageCallback('MsgPlayerDied', handlePlayerDied);
    
    
    function handleAmmoChange(%msgType, %msgString, %ammoType)
    {
       inventory.currentammo=%ammotype;
       ammoInvBitmap.setBitmap("rw/client/ui/" @ %ammoType @ ".png");
       ammoInvText.setText(inventory.itemAmmo_[%ammoType]);
    }
    
    function handleWeaponUsed(%msgType, %msgString, %weaponType)
    {
       inventory.currentweapon=%weapontype;
       weaponInvBitmap.setBitmap("rw/client/ui/" @ %weaponType @ ".png");
       weaponInvText.setText(inventory.currentweapon);
    }
    
    function handleInventory(%msgType, %msgString,%className, %item, %amount)
    {
       inventory.item[%className,%item]=%amount;
       if (%classname $= "Ammo") {
       	if (inventory.currentammo $= "none") {
       		inventory.currentammo=%item;
       		}
       	ammoInvBitmap.setBitmap("rw/client/ui/" @ inventory.currentammo @ ".png");
       	ammoInvText.setText(inventory.itemAmmo_[inventory.currentammo]);
       }
       else if (%classname $= "Weapon") {
       	if (inventory.currentweapon $= "none") {
       		inventory.currentweapon=%item;
       		}
       	ammoInvBitmap.setBitmap("rw/client/ui/" @ inventory.currentweapon @ ".png");
       	ammoInvText.setText(inventory.itemWeapon_[inventory.currentweapon]);
       }
    }
    
    function handlePlayerDied(%msgType, %msgString)
    {
    	inventory.delete();
    	inventory::init();
    }	
    	
    function inventory::init() {
    	%inventory = new ScriptObject(inventory) 
       {
          className = "Inventory";
       };
       inventory.currentammo = "none";
       inventory.currentweapon = "none";
       echo("Inventory: " SPC %inventory);
       
    }
    
    function changeammo(%val)
    {
    	if(%val)
       	commandToServer('changeammo');
    }
    
    moveMap.bind(keyboard, "q", changeammo);
    
    inventory::init();
    
Then create a file in the clien/ui/ folder named ammoInv.gui:

    //--- OBJECT WRITE BEGIN ---
       new GuiControl(ammoInv) {
          profile = "GuiDefaultProfile";
          horizSizing = "left";
          vertSizing = "top";
          position = "576 376";
          extent = "64 104";
          minExtent = "8 8";
          visible = "1";
          helpTag = "0";
    
          new GuiBitmapCtrl(ammoInvBitmap) {
             profile = "GuiDefaultProfile";
             horizSizing = "right";
             vertSizing = "bottom";
             position = "0 6";
             extent = "64 64";
             minExtent = "8 8";
             visible = "1";
             helpTag = "0";
             bitmap = "";
             wrap = "0";
          };
          new GuiTextCtrl(ammoInvText) {
             profile = "HudTextProfile";
             horizSizing = "right";
             vertSizing = "bottom";
             position = "21 73";
             extent = "25 23";
             minExtent = "8 8";
             visible = "1";
             helpTag = "0";
             text = "0";
             maxLength = "4";
          };
       };
    
    
       new GuiControl(weaponInv) {
          profile = "GuiDefaultProfile";
          horizSizing = "left";
          vertSizing = "top";
          position = "512 376";
          extent = "64 104";
          minExtent = "8 8";
          visible = "1";
          helpTag = "0";
    
          new GuiBitmapCtrl(weaponInvBitmap) {
             profile = "GuiDefaultProfile";
             horizSizing = "right";
             vertSizing = "bottom";
             position = "0 6";
             extent = "64 64";
             minExtent = "8 8";
             visible = "1";
             helpTag = "0";
             bitmap = "";
             wrap = "0";
          };
          new GuiTextCtrl(weaponInvText) {
             profile = "HudTextProfile";
             horizSizing = "right";
             vertSizing = "bottom";
             position = "0 73";
             extent = "64 23";
             minExtent = "8 8";
             visible = "1";
             helpTag = "0";
             text = "0";
             maxLength = "4";
          };
       };
    
    //--- OBJECT WRITE END ---
    
    playgui.add(ammoInv);
    playgui.add(weaponInv);
    
Edit client/init.cd add the following lines to the end of the initClient function:

	exec("./ui/ammoInv.gui");
	exec("./scripts/inventory.cs");
	
Finally you will need to add 4 images to your client/ui/ folder:

crossbow.png
crossbowammo1.png	
crossbowammo2.png
crossbowammo3.png

To get the implementation of this download the http://realmwars.feylab.com/downloads/ammoswitch.zip file that includes this text and the files already edited.