1 (edited by trollo159 2017-10-05 09:49:57)

Hello, i looking for sent items to mail if player not have space in bags.

here is part of bool Player::AddItem

/// @todo Send to mailbox if no space
        ChatHandler(GetSession()).PSendSysMessage("You don't have any space in your bags.");
return false;

i found this, compile without error but if i try use it in game, core crashed

bool Player::AddItem(uint32 itemId, uint32 count)
{
    uint32 noSpaceForCount = 0;
    ItemPosCountVec dest;

    if (CanStoreNewItem(NULL_BAG, NULL_SLOT, dest, itemId, count, &noSpaceForCount) != EQUIP_ERR_OK)
    {
        count -= noSpaceForCount;
    }

    if (noSpaceForCount > 0 || dest.empty())
    {
        ItemPrototype const * proto = sObjectMgr.GetItemPrototype(itemId);
        if(!proto)
        {
            sLog.outDebug("Player::AddItem - Can't create prototype for item %u", itemId);
            return false;
        }

        Item *item = NewItemOrBag(proto);
        if(!item)
        {
            sLog.outDebug("Player::AddItem - Can't build new item by his prototype (item %u)", itemId);
            return false;
        }

        ChatHandler(this).PSendSysMessage("You don't have space in your bags for %u items. "
                                          "Remaining items have been sent by mail.", noSpaceForCount);

        for (int i = 0; i < noSpaceForCount; ++i)
        {
            MailDraft draft(GetSession()->GetOregonString(LANG_ITEM_SAVE_FAILED));

            for (int j = 0; j < MAX_MAIL_ITEMS; ++j)
            {
                if(i == noSpaceForCount)
                    break;

                draft.AddItem(item);
                ++i;
            }

            draft.SendMailTo(this, MailSender(this, MAIL_STATIONERY_GM), MAIL_CHECK_MASK_COPIED);
        }
    }

    if (count > 0)
    {
        Item* item = StoreNewItem(dest, itemId, true, Item::GenerateItemRandomPropertyId(itemId));
        if (item)
            SendNewItem(item, count, true, false);
        else
            return false;
    }

    return true;
}

Any ideas? thank you for answers.

Sorry for my bad English smile