Try this
function serverCmdBuy(%client,%image)
{
     if (%image $= "Gun")
     {
      buyThing(%client, GunItem);
     }
}
function buyThing(%client, %thing)
  {
   %slot = -1;
   %item = %thing.getID();
   for (%x=0; %x <= 4; %x++)
     {
      if (%client.player.tool[%x]==0)
        %slot = %x;
      if (%client.player.tool[%x] == %item)
        {
         MessageClient(%client, '', "You already have a " @ %thing.uiName);
         return;
        }
     }
   if (%slot == -1)
     {
      MessageClient(%client, '', "Inventory full");
      return;
     }
   %client.player.tool[%slot] = %item;
   MessageClient(%client, 'MsgItemPickup', '', %slot, %item);
  }
(code ripped from my mining server and tweaked a little)
you can use "buyThing" to add any item to your player inventory if you know the "Item" datablock name.