• 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!
  • If you're using Gesior 2012 or MyAAC, please review this thread for information about a serious security vulnerability and a fix.

Feature Auto Loot Sytem for TFS 1.3

damian00912

Member
Joined
Sep 11, 2009
Messages
89
Reaction score
5
not working :(


Code:
[  1%] Building CXX object CMakeFiles/tfs.dir/src/actions.cpp.o
/home/ot/src/actions.cpp: In member function ‘ReturnValue Actions::internalUseItem(Player*, const Position&, uint8_t, Item*, bool)’:
/home/ot/src/actions.cpp:412:55: error: ‘class Player’ has no member named ‘autoLootList’
     if (player->canOpenCorpse(corpseOwner) && player->autoLootList.size() != 0) {
                                                       ^
/home/giveria/src/actions.cpp:415:29: error: ‘class Player’ has no member named ‘getItemFromAutoLoot’
                 if (player->getItemFromAutoLoot(item->getID())) {
                             ^
CMakeFiles/tfs.dir/build.make:119: recipe for target 'CMakeFiles/tfs.dir/src/actions.cpp.o' failed
make[2]: *** [CMakeFiles/tfs.dir/src/actions.cpp.o] Error 1
CMakeFiles/Makefile2:122: recipe for target 'CMakeFiles/tfs.dir/all' failed
make[1]: *** [CMakeFiles/tfs.dir/all] Error 2
Makefile:76: recipe for target 'all' failed
make: *** [all] Error 2
 

Togu

Advanced OT User
Joined
Jun 22, 2018
Messages
304
Solutions
1
Reaction score
171
Location
Brazil
If somebody want, I can teach how to make a "Loot" option when you ctrl + click on an item to make it automatic.
But you will need OTClient for that. The only thing it does is "say without showing" the talkactions of the system.

Auto-Loot.gif

And you can use this knowledge to do many creative things with talkactions.
 

darkmubr

Member
Joined
Mar 8, 2019
Messages
47
Solutions
1
Reaction score
13
If somebody want, I can teach how to make a "Loot" option when you ctrl + click on an item to make it automatic.
But you will need OTClient for that. The only thing it does is "say without showing" the talkactions of the system.

View attachment 39988

And you can use this knowledge to do many creative things with talkactions.


Could you do this by double clicking on an item?

Then he would be moved to a backpack
 

SUMEKAZEKI

ADM Custom Rook
Joined
Sep 10, 2016
Messages
39
Reaction score
4
Hello, u have this autoloot system on tfs 1.2? And how to edit to modal window
 
Last edited:

heitorzinhotc

Viva la Vida!
Joined
Aug 8, 2008
Messages
65
Reaction score
1
GitHub
htc16
Code:
In file included from /home/server/src/game.h:32:0,
                 from /home/server/src/actions.cpp:28:
/home/server/src/player.h:1464:8: error: ‘set’ in namespace ‘std’ does not name                                                                                         a template type
   std::set<uint32_t> autoLootList;
        ^~~
/home/server/src/actions.cpp: In member function ‘ReturnValue Actions::internalU                                                                                        seItem(Player*, const Position&, uint8_t, Item*, bool)’:
/home/server/src/actions.cpp:419:55: error: ‘class Player’ has no member named ‘                                                                                        autoLootList’
     if (player->canOpenCorpse(corpseOwner) && player->autoLootList.size() != 0)                                                                                         {
                                                       ^~~~~~~~~~~~
/home/server/src/actions.cpp:464:22: error: qualified-id in declaration before ‘                                                                                        (’ token
 bool Actions::useItem(Player* player, const Position& pos, uint8_t index, Item*                                                                                         item, bool isHotkey)
                      ^
/home/server/src/actions.cpp:480:24: error: qualified-id in declaration before ‘                                                                                        (’ token
 bool Actions::useItemEx(Player* player, const Position& fromPos, const Position                                                                                        & toPos,
                        ^
/home/server/src/actions.cpp:517:35: error: qualified-id in declaration before ‘                                                                                        (’ token
 void Actions::showUseHotkeyMessage(Player* player, const Item* item, uint32_t c                                                                                        ount)
                                   ^
/home/server/src/actions.cpp:532:34: error: expected primary-expression before ‘                                                                                        *’ token
 Action::Action(LuaScriptInterface* interface) :
                                  ^
/home/server/src/actions.cpp:532:36: error: ‘interface’ was not declared in this                                                                                         scope
 Action::Action(LuaScriptInterface* interface) :
                                    ^~~~~~~~~
/home/server/src/actions.cpp:532:36: note: suggested alternative: ‘iface’
 Action::Action(LuaScriptInterface* interface) :
                                    ^~~~~~~~~
                                    iface
/home/server/src/actions.cpp:532:45: error: cannot call constructor ‘Action::Act                                                                                        ion’ directly [-fpermissive]
 Action::Action(LuaScriptInterface* interface) :
                                             ^
/home/server/src/actions.cpp:532:45: note: for a function-style cast, remove the                                                                                         redundant ‘::Action’
/home/server/src/actions.cpp:535:28: error: qualified-id in declaration before ‘                                                                                        (’ token
 bool Action::configureEvent(const pugi::xml_node& node)
                            ^
/home/server/src/actions.cpp:555:11: error: expected identifier before ‘{’ token
 namespace {
           ^
/home/server/src/actions.cpp:558:1: error: a function-definition is not allowed                                                                                         here before ‘{’ token
 {
 ^
/home/server/src/actions.cpp:568:1: error: a function-definition is not allowed                                                                                         here before ‘{’ token
 {
 ^
/home/server/src/actions.cpp:597:26: error: qualified-id in declaration before ‘                                                                                        (’ token
 bool Action::loadFunction(const pugi::xml_attribute& attr, bool isScripted)
                          ^
/home/server/src/actions.cpp:617:39: error: qualified-id in declaration before ‘                                                                                        (’ token
 std::string Action::getScriptEventName() const
                                       ^
/home/server/src/actions.cpp:622:37: error: qualified-id in declaration before ‘                                                                                        (’ token
 ReturnValue Action::canExecuteAction(const Player* player, const Position& toPo                                                                                        s)
                                     ^
/home/server/src/actions.cpp:631:25: error: qualified-id in declaration before ‘                                                                                        (’ token
 Thing* Action::getTarget(Player* player, Creature* targetCreature, const Positi                                                                                        on& toPosition, uint8_t toStackPos) const
                         ^
/home/server/src/actions.cpp:631:32: error: expected primary-expression before ‘                                                                                        *’ token
 Thing* Action::getTarget(Player* player, Creature* targetCreature, const Positi                                                                                        on& toPosition, uint8_t toStackPos) const
                                ^
/home/server/src/actions.cpp:631:50: error: expected primary-expression before ‘                                                                                        *’ token
 Thing* Action::getTarget(Player* player, Creature* targetCreature, const Positi                                                                                        on& toPosition, uint8_t toStackPos) const
                                                  ^
/home/server/src/actions.cpp:631:52: error: ‘targetCreature’ was not declared in                                                                                         this scope
 Thing* Action::getTarget(Player* player, Creature* targetCreature, const Positi                                                                                        on& toPosition, uint8_t toStackPos) const
                                                    ^~~~~~~~~~~~~~
/home/server/src/actions.cpp:631:52: note: suggested alternative: ‘_ZTI8Creature                                                                                        ’
 Thing* Action::getTarget(Player* player, Creature* targetCreature, const Positi                                                                                        on& toPosition, uint8_t toStackPos) const
                                                    ^~~~~~~~~~~~~~
                                                    _ZTI8Creature
/home/server/src/actions.cpp:631:68: error: expected primary-expression before ‘                                                                                        const’
 Thing* Action::getTarget(Player* player, Creature* targetCreature, const Positi                                                                                        on& toPosition, uint8_t toStackPos) const
                                                                    ^~~~~
/home/server/src/actions.cpp:631:104: error: expected primary-expression before                                                                                         ‘toStackPos’
 ayer, Creature* targetCreature, const Position& toPosition, uint8_t toStackPos)                                                                                         const
                                                                     ^~~~~~~~~~
/home/server/src/actions.cpp:639:24: error: qualified-id in declaration before ‘                                                                                        (’ token
 bool Action::executeUse(Player* player, Item* item, const Position& fromPositio                                                                                        n, Thing* target, const Position& toPosition, bool isHotkey)
                        ^
/home/server/src/actions.cpp:665:1: error: expected ‘}’ at end of input
 }
 ^
/home/server/src/actions.cpp:665:1: error: control reaches end of non-void funct                                                                                        ion [-Werror=return-type]
 }
 ^
cc1plus: all warnings being treated as errors
CMakeFiles/tfs.dir/build.make:126: recipe for target 'CMakeFiles/tfs.dir/src/act                                                                                        ions.cpp.o' failed
make[2]: *** [CMakeFiles/tfs.dir/src/actions.cpp.o] Error 1
make[2]: *** Waiting for unfinished jobs....
CMakeFiles/Makefile2:99: recipe for target 'CMakeFiles/tfs.dir/all' failed
make[1]: *** [CMakeFiles/tfs.dir/all] Error 2
Makefile:83: recipe for target 'all' failed
make: *** [all] Error 2
 

Ramon Bernardo

Well-Known Member
TFS Developer
Joined
Oct 7, 2018
Messages
137
Solutions
4
Reaction score
91
Good work! ;)

hey @login12 its not working with items that come inside bags on monsters ,can you fix it?and thanks for this great system =)

Thanks for report. I will update this script soon and fix it.

One solution is to duplicate the "for":
Code:
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* itemloot : container->getItemList()) {
                if (Container* containerbag = itemloot->getContainer()) {
                    for (Item* bagitem : containerbag->getItemList()) {
                        if (player->getItemFromAutoLoot(bagitem->getID())) {
                            std::ostringstream msgAutoLoot;
                            msgAutoLoot << "You looted a " << bagitem->getItemCount() << "x " << bagitem->getName() << ".";
                            g_game.internalMoveItem(containerbag, player, CONST_SLOT_WHEREEVER, bagitem, bagitem->getItemCount(), nullptr);
                            player->sendTextMessage(MESSAGE_INFO_DESCR, msgAutoLoot.str());
                        }
                    }
                }
                if (player->getItemFromAutoLoot(itemloot->getID())) {
                    std::ostringstream msgAutoLoot;
                    msgAutoLoot << "You looted a " << itemloot->getItemCount() << "x " << itemloot->getName() << ".";
                    g_game.internalMoveItem(container, player, CONST_SLOT_WHEREEVER, itemloot, itemloot->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)");
        }
    }
}

but it doesn't work if you have a corpse > backpack > backpack > item

sorry bad english :\
 
Last edited:

Lundrial

lundrial:getTitle()
Joined
Apr 15, 2014
Messages
142
Reaction score
101
Location
Chile
a couple of bugs I found on the talkaction scripts:
If you use add or remove without a space it will throw an error in the console and fail to add the item ex:
!autoloot add,gold coin or !autoloot remove,gold coin
if you leave it blank: !autoloot add,<nothinghere>
and the check for unknown item name is also not working ex:
!autoloot add, asdasd
1580166387978.png
Lua:
player:sendTextMessage(MESSAGE_EVENT_ORANGE, "Auto Loot commands (items are automatically moved to your bp if you open monster corpse):"..'\n'.."!addloot add, nameItem - add item to auto loot by name"..'\n'.."!autoloot remove, itemName - remove item from auto loot by name"..'\n'.."!autoloot list - list your current auto loot items")
this should say !autoloot add instead of !addloot add

other than that it's working fine, but one problem I found is that once the owner check expires you stop autolooting, which could be a problem on hectic hunts with a lot of monsters since you don't have time to click the monsters instantly
 

alegeisler

New Member
Joined
Dec 27, 2018
Messages
4
Reaction score
0
Hello people,

I am new to this systems, so please be patient with my ignorance...

I just did all the following steps.

I got nothing.
No errors, no debugs, no result.

Possibly I did something wrong in the Query creation on the database. I am not sure of how can I do this step. Can I please have a little light with that? Any hints or tips to solve this will be appreciated.

Alex.
 

Infernus

Member
Joined
Jul 7, 2008
Messages
250
Reaction score
6
Bug if you have no backpack, the item is taken but goes nowhere. Need to add a check if they have a container.
 

jel

Member
Joined
Mar 22, 2014
Messages
262
Reaction score
11
erro on talkaction
Lua Script Error: [Scripts Interface]
/home/global/data/scripts/talkactions/player/autoloot.lua:callback
...global/data/scripts/talkactions/player/autoloot.lua:24: attempt to index a nil value
stack traceback:
[C]: in function '__index'
...global/data/scripts/talkactions/player/autoloot.lua:24: in function <...global/data/scripts/talkactions/player/autoloot.lua:3>
 

Marevuli

New Member
Joined
Oct 18, 2021
Messages
1
Reaction score
0
Code:
Lua Script Error: [Test Interface]
data/talkactions/scripts/autoloot.lua
LuaScriptInterface::luaCreateTalkaction(). TalkActions can only be registered in the Scripts interface.
stack traceback:
        [C]: in function 'TalkAction'
        data/talkactions/scripts/autoloot.lua:1: in main chunk

Lua Script Error: [Test Interface]
data/talkactions/scripts/autoloot.lua
data/talkactions/scripts/autoloot.lua:3: attempt to index local 'talk' (a nil value)
stack traceback:
        [C]: in function '__newindex'
        data/talkactions/scripts/autoloot.lua:3: in main chunk
[Warning - Event::checkScript] Can not load script: scripts/autoloot.lua

Help?
 
Last edited:
Top