- Joined
- Dec 11, 2007
- Messages
- 3,666
- Solutions
- 1
- Reaction score
- 125
- Location
- Warsaw, Poland
- GitHub
- tayandenga
- Twitch
- tayandenga
Nothing to explain - code limits a player from buying house if his other character already have one.
1. Open player.cpp and at end of file add:
Remember to leave an empty line after it!
Save and close the file.
2. Open player.h and find:
Add below:
Save and close the file.
3. Open commands.cpp and find:
Add below:
Still in same file find:
Add below:
Still in same file find:
Add below:
Still in same file find:
Replace it with:
Save and close the file.
4. Open configmanager.cpp and find:
Add below:
Save and close the file.
5. Open configmanager.h and find:
Add below:
Save and close the file.
Recompile, and add to config.lua an option housesPerOneAccount = X, where X is amount of houses which player can have on one account.
To disable the feature put -1.
Credits to KaczooH for idea and request.
EDIT: Changed 0 to -1 as disabling number.
1. Open player.cpp and at end of file add:
Code:
uint16_t Player::getAccountHousesCount()
{
Account account = IOLoginData::getInstance()->loadAccount(getAccount());
uint32_t _guid;
uint16_t count = 0;
for(std::list<std::string>::iterator it = account.charList.begin(); it != account.charList.end(); it++)
{
IOLoginData::getInstance()->getGuidByName(_guid, (*it));
if(Houses::getInstance().getHouseByPlayerId(_guid))
count++;
}
return count;
}
Save and close the file.
2. Open player.h and find:
Code:
virtual RaceType_t getRace() const {return RACE_BLOOD;}
Code:
uint16_t getAccountHousesCount();
3. Open commands.cpp and find:
Code:
bool Commands::sellHouse(Creature* creature, const std::string& cmd, const std::string& param)
{
Player* player = creature->getPlayer();
Code:
int16_t housesPerAccount = g_config.getNumber(ConfigManager::HOUSES_PER_ACCOUNT);
Code:
if(Houses::getInstance().getHouseByPlayerId(tradePartner->guid))
{
player->sendCancel("Trade player already owns a house.");
return false;
}
Code:
if(housesPerAccount != -1 && tradePartner->getAccountHousesCount() >= housesPerAccount)
{
char buffer[75];
sprintf(buffer, "Trade player has reached limit of %u %s per account.", housesPerAccount, (housesPerAccount == 1 ? "house" : "houses"));
player->sendCancel(buffer);
return false;
}
Code:
bool Commands::buyHouse(Creature* creature, const std::string& cmd, const std::string& param)
{
Player* player = creature->getPlayer();
Code:
int16_t housesPerAccount = g_config.getNumber(ConfigManager::HOUSES_PER_ACCOUNT);
Code:
for(HouseMap::iterator it = Houses::getInstance().getHouseBegin(); it != Houses::getInstance().getHouseEnd(); it++)
{
if(it->second->getHouseOwner() == player->guid)
{
player->sendCancel("You are already the owner of a house.");
return false;
}
}
Code:
if(Houses::getInstance().getHouseByPlayerId(player->getGUID())) //Elf: removed own loop from here
{
player->sendCancel("You are already owner of another house.");
return false;
}
if(housesPerAccount != -1 && player->getAccountHousesCount() >= housesPerAccount)
{
char buffer[50];
sprintf(buffer, "You may own only %u %s per account.", housesPerAccount, (housesPerAccount == 1 ? "house" : "houses"));
player->sendCancel(buffer);
return false;
}
4. Open configmanager.cpp and find:
Code:
m_confString[GENERATE_ACCOUNT_NUMBER] = getGlobalString(L, "generateAccountNumber", "yes");
Code:
m_confInteger[HOUSES_PER_ACCOUNT] = getGlobalNumber(L, "housesPerOneAccount", -1);
5. Open configmanager.h and find:
Code:
STATUSQUERY_TIMEOUT,
Code:
HOUSES_PER_ACCOUNT,
Recompile, and add to config.lua an option housesPerOneAccount = X, where X is amount of houses which player can have on one account.
To disable the feature put -1.
Credits to KaczooH for idea and request.
EDIT: Changed 0 to -1 as disabling number.
Last edited: