return false;
}
}
// Prepare inventory update packet
InventoryUpdate ownerIU = new InventoryUpdate();
InventoryUpdate playerIU = new InventoryUpdate();
// Transfer items
for (ItemRequest item : items)
{
// Check if requested item is sill on the list and adjust its count
adjustItemRequestByItemId(item);
if (item.getCount() == 0) continue;
// Check if requested item is available for manipulation
L2ItemInstance oldItem = player.checkItemManipulation(item.getObjectId(), item.getCount(), "sell");
if (oldItem == null) return false;
// Proceed with item transfer
L2ItemInstance newItem = playerInventory.transferItem("PrivateStore", item.getObjectId(), item.getCount(), ownerInventory, player, _owner);
if (newItem == null) return false;
removeItem(-1, item.getItemId(), item.getCount());
// Add changes to inventory update packets
if (oldItem.getCount() > 0 && oldItem != newItem) playerIU.addModifiedItem(oldItem);
else playerIU.addRemovedItem(oldItem);
if (newItem.getCount() > item.getCount()) ownerIU.addModifiedItem(newItem);
else ownerIU.addNewItem(newItem);
// Send messages about the transaction to both players
if (newItem.isStackable())
{
SystemMessage msg = new SystemMessage(SystemMessageId.PURCHASED_S3_S2_S_FROM_S1);
msg.addString(player.getName());
msg.addItemName(newItem.getItemId());
msg.addNumber(item.getCount());
_owner.sendPacket(msg);
msg = new SystemMessage(SystemMessageId.S1_PURCHASED_S3_S2_S);
msg.addString(_owner.getName());
msg.addItemName(newItem.getItemId());
msg.addNumber(item.getCount());
player.sendPacket(msg);
}
else
{
SystemMessage msg = new SystemMessage(SystemMessageId.PURCHASED_S2_FROM_S1);
msg.addString(player.getName());
msg.addItemName(newItem.getItemId());
_owner.sendPacket(msg);
msg = new SystemMessage(SystemMessageId.S1_PURCHASED_S2);
msg.addString(_owner.getName());
msg.addItemName(newItem.getItemId());
player.sendPacket(msg);
}
}
// Transfer adena
if (price > ownerInventory.getAdena()) return false;
L2ItemInstance adenaItem = ownerInventory.getAdenaInstance();
ownerInventory.reduceAdena("PrivateStore", price, _owner, player);
ownerIU.addItem(adenaItem);
playerInventory.addAdena("PrivateStore", price, player, _owner);
playerIU.addItem(playerInventory.getAdenaInstance());
// Send inventory update packet
_owner.sendPacket(ownerIU);
player.sendPacket(playerIU);
return true;