• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!
  • 2026 staff recruitment is open! Check it out and consider applying!

C++ Move item inbox

Sigoles

Discord: @sigoles
Joined
Nov 20, 2015
Messages
1,209
Solutions
2
Reaction score
154
trying to move the item to the inbox correctly, being container it is not going with the attribute (action and description).

Help?

Pure code:
C++:
ItemList moveItemList;
    for (HouseTile* tile : houseTiles) {
        if (const TileItemVector* items = tile->getItemList()) {
            for (Item* item : *items) {
                if (item->isWrappable()) {
                    item->setIntAttr(ITEM_ATTRIBUTE_ACTIONID, item->getID());
                    std::ostringstream ss;
                    ss << "Unwrap it in your own house to create a <" << item->getName() << ">.";
                    item->setStrAttr(ITEM_ATTRIBUTE_DESCRIPTION, ss.str());
                    moveItemList.push_back(g_game.transformItem(item, 26054));
                } else if (item->isPickupable()) {
                    moveItemList.push_back(item);
                } else {
                    Container* container = item->getContainer();
                    if (container) {
                        for (Item* containerItem : container->getItemList()) {
                            moveItemList.push_back(containerItem);
                        }
                    }
                }
            }
        }
    }

Tried:
C++:
ItemList moveItemList;
    for (HouseTile* tile : houseTiles) {
            if (const TileItemVector* items = tile->getItemList()) {
                for (Item* item : *items) {

                    if (item->isWrappable() && !item->getContainer()) {
                        item->setIntAttr(ITEM_ATTRIBUTE_ACTIONID, item->getID());
                        std::ostringstream ss;
                        ss << "Unwrap it in your own house to create a <" << item->getName() << ">.";
                        item->setStrAttr(ITEM_ATTRIBUTE_DESCRIPTION, ss.str());
                        moveItemList.push_back(g_game.transformItem(item, 26054));
                 
                    } else if (item->isWrappable() && item->getContainer()) {
                        item->setIntAttr(ITEM_ATTRIBUTE_ACTIONID, item->getID());
                        std::ostringstream ss;
                        ss << "Unwrap it in your own house to create a <" << item->getName() << ">.";
                        item->setStrAttr(ITEM_ATTRIBUTE_DESCRIPTION, ss.str());
                        moveItemList.push_back(g_game.transformItem(item, 26054));      
                  
                   
                    } else if (item->isPickupable()) {
                        moveItemList.push_back(item);
                  
                    } else {
                        Container* container = item->getContainer();
                        if (!item->isWrappable() && item->getContainer()) {
                            for (Item* containerItem : container->getItemList()) {
                                moveItemList.push_back(containerItem);
                            }
                        }
                    }
                }
            }
        }

How it should be? tfs 1.2

thanks
 
Solution
Try this:
C++:
ItemList moveItemList;
    for (HouseTile* tile : houseTiles) {
        if (const TileItemVector* items = tile->getItemList()) {
            for (Item* item : *items) {
                if (item->isWrappable()) {
                    std::string itemName = item->getName();
                    uint16_t itemID = item->getID();
                    Item* newItem = g_game.transformItem(item, 26054);
                    newItem->setIntAttr(ITEM_ATTRIBUTE_ACTIONID, itemID);
                    std::ostringstream ss;
                    ss << "Unwrap it in your own house to create a <" << itemName << ">.";
                    newItem->setStrAttr(ITEM_ATTRIBUTE_DESCRIPTION, ss.str())...
trying to move the item to the inbox correctly, being container it is not going with the attribute (action and description).

Help?

Pure code:
C++:
ItemList moveItemList;
    for (HouseTile* tile : houseTiles) {
        if (const TileItemVector* items = tile->getItemList()) {
            for (Item* item : *items) {
                if (item->isWrappable()) {
                    item->setIntAttr(ITEM_ATTRIBUTE_ACTIONID, item->getID());
                    std::ostringstream ss;
                    ss << "Unwrap it in your own house to create a <" << item->getName() << ">.";
                    item->setStrAttr(ITEM_ATTRIBUTE_DESCRIPTION, ss.str());
                    moveItemList.push_back(g_game.transformItem(item, 26054));
                } else if (item->isPickupable()) {
                    moveItemList.push_back(item);
                } else {
                    Container* container = item->getContainer();
                    if (container) {
                        for (Item* containerItem : container->getItemList()) {
                            moveItemList.push_back(containerItem);
                        }
                    }
                }
            }
        }
    }

Tried:
C++:
ItemList moveItemList;
    for (HouseTile* tile : houseTiles) {
            if (const TileItemVector* items = tile->getItemList()) {
                for (Item* item : *items) {

                    if (item->isWrappable() && !item->getContainer()) {
                        item->setIntAttr(ITEM_ATTRIBUTE_ACTIONID, item->getID());
                        std::ostringstream ss;
                        ss << "Unwrap it in your own house to create a <" << item->getName() << ">.";
                        item->setStrAttr(ITEM_ATTRIBUTE_DESCRIPTION, ss.str());
                        moveItemList.push_back(g_game.transformItem(item, 26054));
                
                    } else if (item->isWrappable() && item->getContainer()) {
                        item->setIntAttr(ITEM_ATTRIBUTE_ACTIONID, item->getID());
                        std::ostringstream ss;
                        ss << "Unwrap it in your own house to create a <" << item->getName() << ">.";
                        item->setStrAttr(ITEM_ATTRIBUTE_DESCRIPTION, ss.str());
                        moveItemList.push_back(g_game.transformItem(item, 26054));     
                 
                  
                    } else if (item->isPickupable()) {
                        moveItemList.push_back(item);
                 
                    } else {
                        Container* container = item->getContainer();
                        if (!item->isWrappable() && item->getContainer()) {
                            for (Item* containerItem : container->getItemList()) {
                                moveItemList.push_back(containerItem);
                            }
                        }
                    }
                }
            }
        }

How it should be? tfs 1.2

thanks


The code you modified has no much sense. You are asking the following:

Item is wrappable and not is container -> Do X.
Item is wrappable and is container -> Do X.

all those lines of code will do the same as just
item is wrappable -> Do X.


So basically you did nothing...
 
The code you modified has no much sense. You are asking the following:

Item is wrappable and not is container -> Do X.
Item is wrappable and is container -> Do X.

all those lines of code will do the same as just
item is wrappable -> Do X.


So basically you did nothing...
Ok, wouldn't it be better to explain what the person did (yes I know they copied one block of code and pasted it below) and then ask them what they want to do, then do it for them but explain to them the exact execution of the code so that they have some understanding?
 
Ok, wouldn't it be better to explain what the person did (yes I know they copied one block of code and pasted it below) and then ask them what they want to do, then do it for them but explain to them the exact execution of the code so that they have some understanding?
I know what they want to do, and i explained to him why his code is not working. Im not able right now to make his request, thats why i just point this out. To be honest, im not sure how attributes are handled in items / containers, so im not able to help anymore atm.
 
Try this:
C++:
ItemList moveItemList;
    for (HouseTile* tile : houseTiles) {
        if (const TileItemVector* items = tile->getItemList()) {
            for (Item* item : *items) {
                if (item->isWrappable()) {
                    std::string itemName = item->getName();
                    uint16_t itemID = item->getID();
                    Item* newItem = g_game.transformItem(item, 26054);
                    newItem->setIntAttr(ITEM_ATTRIBUTE_ACTIONID, itemID);
                    std::ostringstream ss;
                    ss << "Unwrap it in your own house to create a <" << itemName << ">.";
                    newItem->setStrAttr(ITEM_ATTRIBUTE_DESCRIPTION, ss.str());
                    moveItemList.push_back(newItem);
                } else if (item->isPickupable()) {
                    moveItemList.push_back(item);
                } else {
                    Container* container = item->getContainer();
                    if (container) {
                        for (Item* containerItem : container->getItemList()) {
                            moveItemList.push_back(containerItem);
                        }
                    }
                }
            }
        }
    }
 
Last edited:
Solution
Try this:
C++:
ItemList moveItemList;
    for (HouseTile* tile : houseTiles) {
        if (const TileItemVector* items = tile->getItemList()) {
            for (Item* item : *items) {
                if (item->isWrappable()) {
                    std::string itemName = item->getName();
                    uint16_t itemID = item->getID();
                    Item* newItem = g_game.transformItem(item, 26054);
                    newItem->setIntAttr(ITEM_ATTRIBUTE_ACTIONID, itemID);
                    std::ostringstream ss;
                    ss << "Unwrap it in your own house to create a <" << itemName << ">.";
                    newItem->setStrAttr(ITEM_ATTRIBUTE_DESCRIPTION, ss.str());
                    moveItemList.push_back(newItem);
                } else if (item->isPickupable()) {
                    moveItemList.push_back(item);
                } else {
                    Container* container = item->getContainer();
                    if (container) {
                        for (Item* containerItem : container->getItemList()) {
                            moveItemList.push_back(containerItem);
                        }
                    }
                }
            }
        }
    }
worked, thanks !!
 

Similar threads

Back
Top