• 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!

Feature Auto Loot Sytem for TFS 1.3

Hello.

Using TFS 1.4.2

I got this error while compiling. Im sure I followed the guide 100% and replaced what was needed.

actions.cpp
C++:
uint32_t corpseOwner = container->getCorpseOwner();
        if (corpseOwner != 0 && !player->canOpenCorpse(corpseOwner)) {
    return RETURNVALUE_YOUARENOTTHEOWNER;
} else {
    if (player->canOpenCorpse(corpseOwner) && player->autoLootList.size() != 0) {
        if (player->getCapacity() > 100 * 100) { //Minimum of Capacity for autoloot works. (100 CAP)
            for (Item* item : container->getItemList()) {
                if (player->getItemFromAutoLoot(item->getID())) {
                    std::ostringstream msgAutoLoot;
                    msgAutoLoot << "You looted a " << item->getItemCount() << "x " << item->getName() << ".";
                    g_game.internalMoveItem(container, player, CONST_SLOT_WHEREEVER, item, item->getItemCount(), nullptr);
                    player->sendTextMessage(MESSAGE_INFO_DESCR, msgAutoLoot.str());
                }
            }
        } else {
            player->sendTextMessage(MESSAGE_INFO_DESCR, "Sorry, you don't have enough capacity to use auto loot, so it has been disabled. (100+ capacity is required)");
        }
    }
}

iologindata.cpp
C++:
//load storage map
    if ((result = db.storeQuery(fmt::format("SELECT `key`, `value` FROM `player_storage` WHERE `player_id` = {:d}", player->getGUID())))) {
        do {
            player->addStorageValue(result->getNumber<uint32_t>("key"), result->getNumber<int32_t>("value"), true);
        } while (result->next());
    }
    query.str(std::string());
    query << "SELECT `autoloot_list` FROM `player_autoloot` WHERE `player_id` = " << player->getGUID();
    if ((result = db.storeQuery(query.str()))) {
        unsigned long lootlistSize;
        const char* autolootlist = result->getStream("autoloot_list", lootlistSize);
        PropStream propStreamList;
        propStreamList.init(autolootlist, lootlistSize);

        int16_t value;
        int16_t item = propStreamList.read<int16_t>(value);
        while (item) {
               player->addItemToAutoLoot(value);
            item = propStreamList.read<int16_t>(value);
        }
    }

1673985947211.png
 
There is any way to replace g_game.internalMoveItem to some function that drop item on the floor if there is no cap/slot free?
 
Hello.

Using TFS 1.4.2

I got this error while compiling. Im sure I followed the guide 100% and replaced what was needed.

actions.cpp
C++:
uint32_t corpseOwner = container->getCorpseOwner();
        if (corpseOwner != 0 && !player->canOpenCorpse(corpseOwner)) {
    return RETURNVALUE_YOUARENOTTHEOWNER;
} else {
    if (player->canOpenCorpse(corpseOwner) && player->autoLootList.size() != 0) {
        if (player->getCapacity() > 100 * 100) { //Minimum of Capacity for autoloot works. (100 CAP)
            for (Item* item : container->getItemList()) {
                if (player->getItemFromAutoLoot(item->getID())) {
                    std::ostringstream msgAutoLoot;
                    msgAutoLoot << "You looted a " << item->getItemCount() << "x " << item->getName() << ".";
                    g_game.internalMoveItem(container, player, CONST_SLOT_WHEREEVER, item, item->getItemCount(), nullptr);
                    player->sendTextMessage(MESSAGE_INFO_DESCR, msgAutoLoot.str());
                }
            }
        } else {
            player->sendTextMessage(MESSAGE_INFO_DESCR, "Sorry, you don't have enough capacity to use auto loot, so it has been disabled. (100+ capacity is required)");
        }
    }
}

iologindata.cpp
C++:
//load storage map
    if ((result = db.storeQuery(fmt::format("SELECT `key`, `value` FROM `player_storage` WHERE `player_id` = {:d}", player->getGUID())))) {
        do {
            player->addStorageValue(result->getNumber<uint32_t>("key"), result->getNumber<int32_t>("value"), true);
        } while (result->next());
    }
    query.str(std::string());
    query << "SELECT `autoloot_list` FROM `player_autoloot` WHERE `player_id` = " << player->getGUID();
    if ((result = db.storeQuery(query.str()))) {
        unsigned long lootlistSize;
        const char* autolootlist = result->getStream("autoloot_list", lootlistSize);
        PropStream propStreamList;
        propStreamList.init(autolootlist, lootlistSize);

        int16_t value;
        int16_t item = propStreamList.read<int16_t>(value);
        while (item) {
               player->addItemToAutoLoot(value);
            item = propStreamList.read<int16_t>(value);
        }
    }

View attachment 72847
C++:
change query.str(std::string());
to
std::ostringstream query;
 
Back
Top