private void ExecuteHandler(ClientSession session) { ItemInstance item = session.Character.Inventory.LoadBySlotAndType(Slot, PartnerBackpack ? InventoryType.PetWarehouse : InventoryType.Warehouse); // actually move the item from source to destination if (item != null && Amount <= item.Amount && Amount > 0) { short?destSlot = session.Character.Inventory.GetFreeSlot(item.Item.Type); // check if the destination slot is out of range if (destSlot == null || destSlot < 0) { return; } // check if the character is allowed to move the item if (session.Character.InExchangeOrTrade) { return; } session.Character.Inventory.MoveItem( PartnerBackpack ? InventoryType.PetWarehouse : InventoryType.Warehouse, item.Item.Type, Slot, Amount, destSlot.Value, out item, out ItemInstance itemdest); if (item != null) { session.SendPacket(PartnerBackpack ? item.GeneratePStash() : item.GenerateStash()); } else { session.SendPacket(PartnerBackpack ? UserInterfaceHelper.Instance.GeneratePStashRemove(Slot) : UserInterfaceHelper.Instance.GenerateStashRemove(Slot)); } if (itemdest != null) { session.SendPacket(itemdest.GenerateInventoryAdd()); } } /* Old code * * ItemInstance previousInventory = session.Character.Inventory.LoadBySlotAndType(Slot, * PetBackpack ? InventoryType.PetWarehouse : InventoryType.Warehouse); * if (Amount <= 0 || previousInventory == null * || Amount > previousInventory.Amount * || !session.Character.Inventory.CanAddItem(previousInventory.ItemVNum)) * { * return; * } * * ItemInstance item2 = previousInventory.DeepCopy(); * item2.Id = Guid.NewGuid(); * item2.Amount = Amount; * * session.Character.Inventory.RemoveItemFromInventory(previousInventory.Id, Amount); * session.Character.Inventory.AddToInventory(item2, item2.Item.Type); * session.Character.Inventory.LoadBySlotAndType(Slot, * PetBackpack ? InventoryType.PetWarehouse : InventoryType.Warehouse); * session.SendPacket(PetBackpack * ? UserInterfaceHelper.Instance.GeneratePStashRemove(Slot) * : UserInterfaceHelper.Instance.GenerateStashRemove(Slot)); */ }