diff --git a/src/creatures/npcs/npc.cpp b/src/creatures/npcs/npc.cpp index 6d38524aef3..05f22780ada 100644 --- a/src/creatures/npcs/npc.cpp +++ b/src/creatures/npcs/npc.cpp @@ -387,6 +387,13 @@ void Npc::onPlayerSellItem(std::shared_ptr player, uint16_t itemId, uint continue; } + if (const auto &container = item->getContainer()) { + if (container->size() > 0) { + player->sendTextMessage(MESSAGE_EVENT_ADVANCE, "You must empty the container before selling it."); + continue; + } + } + if (parent && item->getParent() != parent) { continue; } diff --git a/src/creatures/players/player.cpp b/src/creatures/players/player.cpp index f9fafee1f14..b923dd952d2 100644 --- a/src/creatures/players/player.cpp +++ b/src/creatures/players/player.cpp @@ -4120,6 +4120,12 @@ std::map &Player::getAllItemTypeCount(std::map &Player::getAllSaleItemIdAndCount(std::map &countMap) const { for (const auto &item : getAllInventoryItems(false, true)) { + if (const auto &container = item->getContainer()) { + if (container->size() > 0) { + continue; + } + } + countMap[item->getID()] += item->getItemCount(); }