Hallo,
versuche seit einiger Zeit den Rucksack auszulesen (Item* Player::GetItemByPos(uint8 bag, uint8 slot) const), jedoch finde ich den Standard-Rucksack mit den 16 Plätzen nicht…
Könnte mir da jemand weiterhelfen ?
Hello,
I’m trying since a while to get all the items from the backpack (Item* Player::GetItemByPos(uint8 bag, uint8 slot) const), sadly I’m unable to find the backpack with the 16 slots…
Could someone help me with it ?
Test code - for now just trying to get the Item pointer.
bool OnUse(Player *pUser, Item *pItem, const SpellCastTargets &pTarget) override
std::vector<std::pair<Bag*, Item*> > BagItemTestHolder;
for (int i = 0; i < 16; i++) //Guess
{
Item *item = pUser->GetItemByPos(INVENTORY_SLOT_BAG_0, i);
BagItemTestHolder.push_back(std::make_pair(item ? item->GetContainer() : nullptr, item));
}
for (int i = 0; i < 4; i++) //Guess
{
for (int j = 0; j < 255; j++) //Guess
{
Item *item = pUser->GetItemByPos(INVENTORY_SLOT_BAG_START + j, i);
BagItemTestHolder.push_back(std::make_pair(item ? item->GetContainer() : nullptr, item));
}
}
//[...]
uint32 counter = 0;
for (std::vector<std::pair<Bag*, Item*> >::iterator viItr = BagItemTestHolder.begin(); viItr != BagItemTestHolder.end(); ++viItr)
{
if (viItr->second)
{
if (viItr->first)
{
ChatHandler(pUser->GetSession()).PSendSysMessage("Got a valid item in vector position %u", counter);
ChatHandler(pUser->GetSession()).PSendSysMessage("Bag ID = %u and Item entry ID = %u", (*viItr).first->GetBagSlot(), (*viItr).second->GetEntry());
}
}
++counter;
}