• 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 [TFS 1.3]

not working! testet tfs 1.3 OTX 3.10
Code:
/home/otx/src/luascript.cpp: In function ‘int luaPlayerGetAutoLootList(lua_State*)’:
/home/otx/src/luascript.cpp:295:22: error: ‘getUserdata’ was not declared in this scope
     Player* player = getUserdata<Player>(L, 1);
                      ^
/home/otx/src/luascript.cpp:295:40: error: expected primary-expression before ‘>’ token
     Player* player = getUserdata<Player>(L, 1);
                                        ^
In file included from /home/otx/src/luascript.cpp:26:0:
/home/otx/src/player.h:1253:22: error: ‘std::set<unsigned int> Player::autoLootList’ is protected
   std::set<uint32_t> autoLootList;
                      ^
/home/otx/src/luascript.cpp:298:44: error: within this context
         std::set<uint32_t> value = player->autoLootList;
                                            ^
/home/otx/src/luascript.cpp: At global scope:
/home/otx/src/luascript.cpp:319:65: error: no ‘int LuaScriptInterface::luaPlayerRemoveAutoLootItem(lua_State*)’ member function declared in class ‘LuaScriptInterface’
int LuaScriptInterface::luaPlayerRemoveAutoLootItem(lua_State* L)
                                                                 ^
/home/otx/src/luascript.cpp:345:62: error: no ‘int LuaScriptInterface::luaPlayerGetAutoLootItem(lua_State*)’ member function declared in class ‘LuaScriptInterface’
int LuaScriptInterface::luaPlayerGetAutoLootItem(lua_State* L)
                                                              ^
/home/otx/src/luascript.cpp:374:62: error: no ‘int LuaScriptInterface::luaPlayerGetAutoLootList(lua_State*)’ member function declared in class ‘LuaScriptInterface’
int LuaScriptInterface::luaPlayerGetAutoLootList(lua_State* L)
                                                              ^
/home/otx/src/luascript.cpp: In member function ‘void LuaScriptInterface::registerFunctions()’:
/home/otx/src/luascript.cpp:2243:46: error: ‘luaPlayerAddAutoLootItem’ is not a member of ‘LuaScriptInterface’
  registerMethod("Player", "AddAutoLootItem", LuaScriptInterface::luaPlayerAddAutoLootItem);
                                              ^
/home/otx/src/luascript.cpp:2244:52: error: ‘luaPlayerRemoveAutoLootItem’ is not a member of ‘LuaScriptInterface’
     registerMethod("Player", "RemoveAutoLootItem", LuaScriptInterface::luaPlayerRemoveAutoLootItem);
                                                    ^
/home/otx/src/luascript.cpp:2245:49: error: ‘luaPlayerGetAutoLootItem’ is not a member of ‘LuaScriptInterface’
     registerMethod("Player", "GetAutoLootItem", LuaScriptInterface::luaPlayerGetAutoLootItem);
                                                 ^
/home/otx/src/luascript.cpp:2246:49: error: ‘luaPlayerGetAutoLootList’ is not a member of ‘LuaScriptInterface’
     registerMethod("Player", "GetAutoLootList", LuaScriptInterface::luaPlayerGetAutoLootList);
                                                 ^
make[2]: *** [CMakeFiles/tfs.dir/src/luascript.cpp.o] Error 1
make[1]: *** [CMakeFiles/tfs.dir/all] Error 2
make: *** [all] Error 2

Code:
Scanning dependencies of target tfs
[  1%] Building CXX object CMakeFiles/tfs.dir/src/luascript.cpp.o
/home/otx/src/luascript.cpp: In function ‘int luaPlayerGetAutoLootList(lua_State*)’:
/home/otx/src/luascript.cpp:295:22: error: ‘getUserdata’ was not declared in this scope
     Player* player = getUserdata<Player>(L, 1);
                      ^
/home/otx/src/luascript.cpp:295:40: error: expected primary-expression before ‘>’ token
     Player* player = getUserdata<Player>(L, 1);
                                        ^
In file included from /home/otx/src/luascript.cpp:26:0:
/home/otx/src/player.h:1253:22: error: ‘std::set<unsigned int> Player::autoLootList’ is protected
   std::set<uint32_t> autoLootList;
                      ^
/home/otx/src/luascript.cpp:298:44: error: within this context
         std::set<uint32_t> value = player->autoLootList;
                                            ^
/home/otx/src/luascript.cpp: At global scope:
/home/otx/src/luascript.cpp:319:65: error: no ‘int LuaScriptInterface::luaPlayerRemoveAutoLootItem(lua_State*)’ member function declared in class ‘LuaScriptInterface’
int LuaScriptInterface::luaPlayerRemoveAutoLootItem(lua_State* L)
                                                                 ^
/home/otx/src/luascript.cpp:345:62: error: no ‘int LuaScriptInterface::luaPlayerGetAutoLootItem(lua_State*)’ member function declared in class ‘LuaScriptInterface’
int LuaScriptInterface::luaPlayerGetAutoLootItem(lua_State* L)
                                                              ^
/home/otx/src/luascript.cpp:374:62: error: no ‘int LuaScriptInterface::luaPlayerGetAutoLootList(lua_State*)’ member function declared in class ‘LuaScriptInterface’
int LuaScriptInterface::luaPlayerGetAutoLootList(lua_State* L)
                                                              ^
/home/otx/src/luascript.cpp: In member function ‘void LuaScriptInterface::registerFunctions()’:
/home/otx/src/luascript.cpp:2243:46: error: ‘luaPlayerAddAutoLootItem’ is not a member of ‘LuaScriptInterface’
  registerMethod("Player", "AddAutoLootItem", LuaScriptInterface::luaPlayerAddAutoLootItem);
                                              ^
/home/otx/src/luascript.cpp:2244:52: error: ‘luaPlayerRemoveAutoLootItem’ is not a member of ‘LuaScriptInterface’
     registerMethod("Player", "RemoveAutoLootItem", LuaScriptInterface::luaPlayerRemoveAutoLootItem);
                                                    ^
/home/otx/src/luascript.cpp:2245:49: error: ‘luaPlayerGetAutoLootItem’ is not a member of ‘LuaScriptInterface’
     registerMethod("Player", "GetAutoLootItem", LuaScriptInterface::luaPlayerGetAutoLootItem);
                                                 ^
/home/otx/src/luascript.cpp:2246:49: error: ‘luaPlayerGetAutoLootList’ is not a member of ‘LuaScriptInterface’
     registerMethod("Player", "GetAutoLootList", LuaScriptInterface::luaPlayerGetAutoLootList);
                                                 ^
make[2]: *** [CMakeFiles/tfs.dir/src/luascript.cpp.o] Error 1
make[1]: *** [CMakeFiles/tfs.dir/all] Error 2
make: *** [all] Error 2
root@instance-1:/home/otx/build# ^C
root@instance-1:/home/otx/build#
 
ok, error change now:
[ 45%] Building CXX object CMakeFiles/tfs.dir/src/luascript.cpp.o
/home/rmglasspe/servidor/source/src/luascript.cpp:12743:62: error: no ‘int LuaSc riptInterface::luaPlayerAddAutoLootItem(lua_State*)’ member function declared in class ‘LuaScriptInterface’
int LuaScriptInterface::luaPlayerAddAutoLootItem(lua_State* L)
^
/home/rmglasspe/servidor/source/src/luascript.cpp:12767:65: error: no ‘int LuaSc riptInterface::luaPlayerRemoveAutoLootItem(lua_State*)’ member function declared in class ‘LuaScriptInterface’
int LuaScriptInterface::luaPlayerRemoveAutoLootItem(lua_State* L)
^
/home/rmglasspe/servidor/source/src/luascript.cpp:12793:62: error: no ‘int LuaSc riptInterface::luaPlayerGetAutoLootItem(lua_State*)’ member function declared in class ‘LuaScriptInterface’
int LuaScriptInterface::luaPlayerGetAutoLootItem(lua_State* L)
^
/home/rmglasspe/servidor/source/src/luascript.cpp:12822:62: error: no ‘int LuaSc riptInterface::luaPlayerGetAutoLootList(lua_State*)’ member function declared in class ‘LuaScriptInterface’
int LuaScriptInterface::luaPlayerGetAutoLootList(lua_State* L)
^
make[2]: *** [CMakeFiles/tfs.dir/src/luascript.cpp.o] Error 1
make[1]: *** [CMakeFiles/tfs.dir/all] Error 2
make: *** [all] Error 2

anynone can help me again ?
 
Guys, if you have problem to comp.. follow the help of some here and at the end change this line:
C++:
if (autolooted != "" and corpse->getContentDescription() == "nothing") {
For this:
C++:
if (autolooted != "" || corpse->getContentDescription() == "nothing") {

Correct compilation but when I execute the command it presents error. Has anyone had this problem?

WOMV4XZWRSSoUertD5Riug.jpeg


Sorry spam, but i can't edit.
SOLVED my problem above:
Just edit 1st letter uppercase by lowercase and change the other codes if they are also uppercase. (I do not remember where I changed, take a look at the overall).

C++:
    registerMethod("Player", "addAutoLootItem", LuaScriptInterface::luaPlayerAddAutoLootItem);
    registerMethod("Player", "removeAutoLootItem", LuaScriptInterface::luaPlayerRemoveAutoLootItem);
    registerMethod("Player", "getAutoLootItem", LuaScriptInterface::luaPlayerGetAutoLootItem);
    registerMethod("Player", "getAutoLootList", LuaScriptInterface::luaPlayerGetAutoLootList);

But I still have a problem, as print below:
(A constructive criticism, because the developer manages to make it work and provides the code that needs to be all changed for it to work since the version is 1.3 and the most ppl are using here?)
Yi2GyG5ER76SEZn4udV0UA.jpeg
 
Last edited by a moderator:
You cannot do this type of spam friend!!! First find all your problems and then comment what you need...
 
You cannot do this type of spam friend!!! First find all your problems and then comment what you need...

You said something I already know and explained. I even apologized. However, I helped with information that I made work. And I took the opportunity to ask a question. Anyway, thanks for the alert and sorry again.
 
You said something I already know and explained. I even apologized. However, I helped with information that I made work. And I took the opportunity to ask a question. Anyway, thanks for the alert and sorry again.
You shouldnt even post here with help or any other person, its resources board. If you have problem with system/code, post it in support and link the thread if its on otland.
 
You shouldnt even post here with help or any other person, its resources board. If you have problem with system/code, post it in support and link the thread if its on otland.
I domt agree with you. If theres doubts regarding the system, those should be posted here. Otherwise everything is a mess.
 
[QUOTE = "samco, post: 2514935, member: 890"] Por que melhor? Eu acho que esse sistema é bem completo. [/ QUOTE]
https://i.imgur.com/88Ej4t0.png [/ img]
[img] https://i.imgur.com/pMYheEo.png [/ img]

:rolleyes:
 
[QUOTE = "samco, post: 2514935, member: 890"] Por que melhor? Eu acho que esse sistema é bem completo. [/ QUOTE]
https://i.imgur.com/88Ej4t0.png [/ img]
https://i.imgur.com/pMYheEo.png [/ img]

:rolleyes:[/QUOTE]
1 thing, try to fix your post.

2nd thing: this is complete, you can add and remove items from autoloot list.
Yes its great to have modals (i dont think they are that usefull in this case).

Are you going to share that, then?
 
Anyone that made that work can remake the tutorial, please?

I couldn't make that work so I tried to "clone" the loots to owner's backpack, adding this line:
C++:
g_game.internalPlayerAddItem(owner, item, true, CONST_SLOT_WHEREEVER);

Under:
C++:
corpse->internalAddThing(item);

But it don't work. And if I try to print a message like this in this block:
C++:
std::ostringstream teste;
teste<< "Teste 1";
owner->sendTextMessage(MESSAGE_LOOT, teste.str());

It don't print.

AUTO LOOT GOLD AND PLATINUM COINS BY TOGU

replace your void MonsterType::createLoot(Container* corpse) function for that:

C++:
void MonsterType::createLoot(Container* corpse)
{
   if (g_config.getNumber(ConfigManager::RATE_LOOT) == 0) {
       corpse->startDecaying();
       return;
   }

   Player* owner = g_game.getPlayerByID(corpse->getCorpseOwner());
   if (!owner || owner->getStaminaMinutes() > 840) {

       int goldCoins = 0;
       int platinumCoins = 0;

       std::ostringstream ss;
       ss << "Loot of " << nameDescription << ": ";

       for (auto it = info.lootItems.rbegin(), end = info.lootItems.rend(); it != end; ++it) {
           auto itemList = createLootItem(*it);
           if (itemList.empty()) {
               continue;
           }

           for (Item* item : itemList) {

               //auto loot gold coin and platinum coin
               if (item->getID() == 2148 || item->getID() == 2152) {
                   if (item->getID() == 2148) {
                       goldCoins = item->getItemCount();
                   }
                   if (item->getID() == 2152) {
                       platinumCoins = item->getItemCount();
                   }
                   g_game.internalPlayerAddItem(owner, item, true, CONST_SLOT_WHEREEVER);
               }

               //check containers
               if (Container* container = item->getContainer()) {
                   if (!createLootContainer(container, *it)) {
                       delete container;
                       continue;
                   }
               }

               //changed for auto loot
               if (item->getID() != 2148 && item->getID() != 2152) {
                   if (g_game.internalAddItem(corpse, item) != RETURNVALUE_NOERROR) {
                       corpse->internalAddThing(item);
                   }
               }
           }
       }

       if (owner) {

           if (goldCoins > 0) {
               if (goldCoins == 1) {
                   ss << goldCoins << " gold coin, ";
               }
               else if (goldCoins > 1) {
                   ss << goldCoins << " gold coins, ";
               }
           }

           if (platinumCoins > 0) {
               if (platinumCoins == 1) {
                   ss << platinumCoins << " platinum coin, ";
               }
               else if (platinumCoins > 1) {
                   ss << platinumCoins << " platinum coins, ";
               }
           }

           ss << corpse->getContentDescription();

           if (owner->getParty()) {
               owner->getParty()->broadcastPartyLoot(ss.str());
           } else {
               owner->sendTextMessage(MESSAGE_LOOT, ss.str());
           }
       }
   } else {
       std::ostringstream ss;
       ss << "nothing (due to low stamina)";

       if (owner->getParty()) {
           owner->getParty()->broadcastPartyLoot(ss.str());
       } else {
           owner->sendTextMessage(MESSAGE_LOOT, ss.str());
       }
   }

   corpse->startDecaying();
}
 
Last edited by a moderator:
Its working. I have this implemented in my server...
 
But definitely the topic need a remake. The first message gives many compiling errors, then the other messages don't have the full solution, everything is a mess.
But I'm happy it inspired me to make the auto loot gold, thats good enough.
 
Not true, the messages in here leads to the corrections needed in the code.
 
Back
Top