void Commands::sellHouse(Player& player, const std::string& param) { Player* tradePartner = g_game.getPlayerByName(param); if (!tradePartner || tradePartner == &player) { player.sendCancel("Trade player not found."); return; } if (!Position::areInRange<2, 2, 0>(tradePartner->getPosition(), player.getPosition())) { player.sendCancel("Trade player is too far away."); return; } if (!tradePartner->isPremium()) { player.sendCancel("Trade player does not have a premium account."); return; } HouseTile* houseTile = dynamic_cast<HouseTile*>(player.getTile()); if (!houseTile) { player.sendCancel("You must stand in your house to initiate the trade."); return; } House* house = houseTile->getHouse(); if (!house || house->getOwner() != player.getGUID()) { player.sendCancel("You don't own this house."); return; } if (Houses::getInstance().getHouseByPlayerId(tradePartner->getGUID())) { player.sendCancel("Trade player already owns a house."); return; } if (IOLoginData::hasBiddedOnHouse(tradePartner->getGUID())) { player.sendCancel("Trade player is currently the highest bidder of an auctioned house."); return; } Item* transferItem = house->getTransferItem(); if (!transferItem) { player.sendCancel("You can not trade this house."); return; } transferItem->getParent()->setParent(&player); if (!g_game.internalStartTrade(&player, tradePartner, transferItem)) { house->resetTransferItem(); } }
void Commands::sellHouse(Player* player, const std::string& cmd, const std::string& param) { House* house = Houses::getInstance().getHouseByPlayerId(player->guid); if (!house) { player->sendCancel("You do not own any house."); return; } Player* tradePartner = g_game.getPlayerByName(param); if (!(tradePartner && tradePartner != player)) { player->sendCancel("Trade player not found."); return; } if (tradePartner->level < 1) { player->sendCancel("Trade player level is too low."); return; } if (!Position::areInRange<2, 2, 0>(tradePartner->getPosition(), player->getPosition())) { player->sendCancel("Trade player is too far away."); return; } if (!tradePartner->isPremium()) { player->sendCancel("Trade player does not have a premium account."); return; } if (Houses::getInstance().getHouseByPlayerId(tradePartner->guid)) { player->sendCancel("Trade player already owns a house."); return; } if (IOLoginData::getInstance()->hasBiddedOnHouse(tradePartner->guid)) { player->sendCancel("Trade player is currently the highest bidder of an auctioned house."); return; } Item* transferItem = house->getTransferItem(); if (!transferItem) { player->sendCancel("You can not trade this house."); return; } transferItem->getParent()->setParent(player); if (!g_game.internalStartTrade(player, tradePartner, transferItem)) { house->resetTransferItem(); } }
bool Commands::sellHouse(Creature* creature, const std::string& cmd, const std::string& param) { Player* player = creature->getPlayer(); if(player){ House* house = Houses::getInstance().getHouseByPlayerId(player->getGUID()); if(!house){ player->sendCancel("You do not own any house."); return false; } Player* tradePartner = g_game.getPlayerByName(param); if(!(tradePartner && tradePartner != player)){ player->sendCancel("Trade player not found."); return false; } if(tradePartner->getPlayerInfo(PLAYERINFO_LEVEL) < 1){ player->sendCancel("Trade player level is too low."); return false; } if(Houses::getInstance().getHouseByPlayerId(tradePartner->getGUID())){ player->sendCancel("Trade player already owns a house."); return false; } if(!Position::areInRange<2,2,0>(tradePartner->getPosition(), player->getPosition())){ player->sendCancel("Trade player is too far away."); return false; } Item* transferItem = house->getTransferItem(); if(!transferItem){ player->sendCancel("You can not trade this house."); return false; } transferItem->getParent()->setParent(player); if(g_game.internalStartTrade(player, tradePartner, transferItem)){ return true; } else{ house->resetTransferItem(); } } return false; }
bool TalkAction::sellHouse(Player* player, const std::string& words, const std::string& param) { if (!player) { return false; } House* house = Houses::getInstance().getHouseByPlayerId(player->getGUID()); if (!house) { player->sendCancel("You do not own any house."); return false; } if (!Houses::getInstance().payRent(player, house)) { player->sendCancel("You have to pay the rent before selling your house and you do not have enough money."); return false; } Player* tradePartner = g_game.getPlayerByName(param); if (!(tradePartner && tradePartner != player)) { player->sendCancel("Trade player not found."); return false; } if (!tradePartner->isPremium() && g_config.getNumber(ConfigManager::HOUSE_ONLY_PREMIUM)) { player->sendCancel("Trade player doesn't have a premium account."); return false; } if (tradePartner->getPlayerInfo(PLAYERINFO_LEVEL) < g_config.getNumber(ConfigManager::HOUSE_LEVEL)) { player->sendCancel("Trade player level is too low."); return false; } if (Houses::getInstance().getHouseByPlayerId(tradePartner->getGUID())) { player->sendCancel("Trade player already owns a house."); return false; } if (!Position::areInRange<2, 2, 0>(tradePartner->getPosition(), player->getPosition())) { player->sendCancel("Trade player is too far away."); return false; } Item* transferItem = house->getTransferItem(); if (!transferItem) { player->sendCancel("You can not trade this house."); return false; } transferItem->getParent()->setParent(player); if (g_game.internalStartTrade(player, tradePartner, transferItem)) { return true; } else { house->resetTransferItem(); } return false; }