bpm91
Intermediate OT User
- Joined
- May 23, 2019
- Messages
- 928
- Solutions
- 7
- Reaction score
- 127
- Location
- Brazil
- YouTube
- caruniawikibr
hello, could someone help me to make the items instead of going to the deposit, they go to a SQL file for example from the database? eg deposit_website
then I could send the items from the site to the desired deposit little by little as I have space in the deposits.
then I could send the items from the site to the desired deposit little by little as I have space in the deposits.
Lua:
void House::setOwner(uint32_t guid, bool updateDatabase/* = true*/, Player* player/* = nullptr*/)
{
if (updateDatabase && owner != guid) {
Database& db = Database::getInstance();
db.executeQuery(fmt::format("UPDATE `houses` SET `owner` = {:d}, `bid` = 0, `bid_end` = 0, `last_bid` = 0, `highest_bidder` = 0 WHERE `id` = {:d}", guid, id));
}
if (isLoaded && owner == guid) {
return;
}
isLoaded = true;
if (owner != 0) {
//send items to depot
if (player) {
transferToDepot(player);
} else {
transferToDepot();
}
for (HouseTile* tile : houseTiles) {
if (const CreatureVector* creatures = tile->getCreatures()) {
for (int32_t i = creatures->size(); --i >= 0;) {
kickPlayer(nullptr, (*creatures)[i]->getPlayer());
}
}
}
// Remove players from beds
for (BedItem* bed : bedsList) {
if (bed->getSleeper() != 0) {
bed->wakeUp(nullptr);
}
}
//clean access lists
owner = 0;
ownerAccountId = 0;
setAccessList(SUBOWNER_LIST, "");
setAccessList(GUEST_LIST, "");
for (Door* door : doorSet) {
door->setAccessList("");
}
} else {
std::string strRentPeriod = asLowerCaseString(g_config.getString(ConfigManager::HOUSE_RENT_PERIOD));
time_t currentTime = time(nullptr);
if (strRentPeriod == "yearly") {
currentTime += 24 * 60 * 60 * 365;
} else if (strRentPeriod == "monthly") {
currentTime += 24 * 60 * 60 * 30;
} else if (strRentPeriod == "weekly") {
currentTime += 24 * 60 * 60 * 7;
} else if (strRentPeriod == "daily") {
currentTime += 24 * 60 * 60;
} else {
currentTime = 0;
}
paidUntil = currentTime;
}
rentWarnings = 0;
if (guid != 0) {
std::string name = IOLoginData::getNameByGuid(guid);
if (!name.empty()) {
owner = guid;
ownerName = name;
ownerAccountId = IOLoginData::getAccountIdByPlayerName(name);
}
}
updateDoorDescription();
}
Lua:
bool House::transferToDepot() const
{
if (townId == 0 || owner == 0) {
return false;
}
Player* player = g_game.getPlayerByGUID(owner);
if (player) {
transferToDepot(player);
} else {
Player tmpPlayer(nullptr);
if (!IOLoginData::loadPlayerById(&tmpPlayer, owner)) {
return false;
}
transferToDepot(&tmpPlayer);
IOLoginData::savePlayer(&tmpPlayer);
}
return true;
}
bool House::transferToDepot(Player* player) const
{
if (townId == 0 || owner == 0) {
return false;
}
ItemList moveItemList;
for (HouseTile* tile : houseTiles) {
if (const TileItemVector* items = tile->getItemList()) {
for (Item* item : *items) {
if (item->isPickupable() && !item->isLoadedFromMap()) {
moveItemList.push_back(item);
} else {
Container* container = item->getContainer();
if (container) {
for (Item* containerItem : container->getItemList()) {
moveItemList.push_back(containerItem);
}
}
}
}
}
}
for (Item* item : moveItemList) {
if (DepotLocker* depotLocker = player->getDepotLocker(townId)) {
g_game.internalMoveItem(item->getParent(), depotLocker, INDEX_WHEREEVER, item, item->getItemCount(), nullptr, FLAG_NOLIMIT);
}
}
return true;
}
Last edited: