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

Solved doSaveHouse for 0.36pl1 ?? PLEASE?

luascript.cpp
Code:
  //doSaveHouse({list})
   lua_register(m_luaState, "doSaveHouse", LuaScriptInterface::luaDoSaveHouse);

Code:
int32_t LuaScriptInterface::luaDoSaveHouse(lua_State* L)
{
   //doSaveHouse({list})
   IntegerVec list;
   if(lua_istable(L, -1))
   {
     lua_pushnil(L);
     while(lua_next(L, -2))
       list.push_back(popNumber(L));

     lua_pop(L, 2);
   }
   else
     list.push_back(popNumber(L));

   House* house;
   std::vector<House*> houses;
   for(IntegerVec::const_iterator it = list.begin(); it != list.end(); ++it)
   {
     if(!(house = Houses::getInstance()->getHouse(*it)))
     {
       std::stringstream s;
       s << "House not found, ID: " << (*it);
       errorEx(s.str());

       lua_pushboolean(L, false);
       return 1;
     }

     houses.push_back(house);
   }

   Database* db = Database::getInstance();
   DBTransaction trans(db);
   if(!trans.begin())
   {
     lua_pushboolean(L, false);
     return 1;
   }

   for(std::vector<House*>::iterator it = houses.begin(); it != houses.end(); ++it)
   {
     if(!IOMapSerialize::getInstance()->saveHouse(db, *it))
     {
       std::stringstream s;
       s << "Unable to save house information, ID: " << (*it)->getId();
       errorEx(s.str());
     }

     if(!IOMapSerialize::getInstance()->saveHouseItems(db, *it))
     {
       std::stringstream s;
       s << "Unable to save house items, ID: " << (*it)->getId();
       errorEx(s.str());
     }
   }

   lua_pushboolean(L, trans.commit());
   return 1;
}

luascript.h
Code:
    static int32_t luaDoSaveHouse(lua_State* L);
 
Back
Top