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

House limits per account

elf

Sing, sing blue silver
Senator
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:
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;
}
Remember to leave an empty line after it!
Save and close the file.

2. Open player.h and find:
Code:
virtual RaceType_t getRace() const {return RACE_BLOOD;}
Add below:
Code:
uint16_t getAccountHousesCount();
Save and close the file.

3. Open commands.cpp and find:
Code:
bool Commands::sellHouse(Creature* creature, const std::string& cmd, const std::string& param)
{
	Player* player = creature->getPlayer();
Add below:
Code:
int16_t housesPerAccount = g_config.getNumber(ConfigManager::HOUSES_PER_ACCOUNT);
Still in same file find:
Code:
		if(Houses::getInstance().getHouseByPlayerId(tradePartner->guid))
		{
			player->sendCancel("Trade player already owns a house.");
			return false;
		}
Add below:
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;
		}
Still in same file find:
Code:
bool Commands::buyHouse(Creature* creature, const std::string& cmd, const std::string& param)
{
	Player* player = creature->getPlayer();
Add below:
Code:
int16_t housesPerAccount = g_config.getNumber(ConfigManager::HOUSES_PER_ACCOUNT);
Still in same file find:
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;
			}
		}
Replace it with:
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;
		}
Save and close the file.

4. Open configmanager.cpp and find:
Code:
m_confString[GENERATE_ACCOUNT_NUMBER] = getGlobalString(L, "generateAccountNumber", "yes");
Add below:
Code:
m_confInteger[HOUSES_PER_ACCOUNT] = getGlobalNumber(L, "housesPerOneAccount", -1);
Save and close the file.

5. Open configmanager.h and find:
Code:
STATUSQUERY_TIMEOUT,
Add below:
Code:
HOUSES_PER_ACCOUNT,
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.
 
Last edited:
Credits to FightingElf for making a code:* My idea would be nothing if you didn't make it true with coding it.

What do you think about cleaning houses whos owner wasn't online for x days? I think that cleaing house as his pacc goes down isn't a good idea. He might be out or something. What Elf do you think about it?
 
Credits to FightingElf for making a code:* My idea would be nothing if you didn't make it true with coding it.

What do you think about cleaning houses whos owner wasn't online for x days? I think that cleaing house as his pacc goes down isn't a good idea. He might be out or something. What Elf do you think about it?
Great allthough insane idea. I'll write it when I get my notebook alive :p
 
"if(housesPerAccount != 0 && player->getAccountHousesCount() > housesPerAccount)" Shouldn't it be >= ;> Cause now I'm able to buy 2 houses on 1 acc
 
this is good code but all it does is annoy players who want to houses all they have to do is make another account say they play 2 characters they just need to make them on 2 different accounts which doesn't bother them at all even if they MC so its good but it doesn't stop this to much 1 player can still own several hoouses
 
I don't understand you English - it's kinda messy. Anyway, on some servers there are houses only for pacc and the pacc is pucharced by real money so that's nice IMO. I have a question that ive asked above.
 
"if(housesPerAccount != 0 && player->getAccountHousesCount() > housesPerAccount)" Shouldn't it be >= ;> Cause now I'm able to buy 2 houses on 1 acc
Then change.

Yes guys, I agree, that players won't be so kind since they have premmy for real money - eg. I have 100 days, its pointless to charge second account also for 100 just to buy a house.
 
@kaczooH
my English? it might be hard to understand, ya my grammar sucks

@topic
well if your players have to but premmy for rl money well then i see it stopping them and this being a useful script, or maybe if it premmy costs a lot like on World of LastWar
 
@Soul4soul - Maybe use commas, capitals and so?:p

@Elf - I don't really know if it should be >= by that what my mathematical instinct says to me. I don't know C++ that much. Yet :)

@Topic - The purpouse of this script is to avoid making MAX_ALLOWED_CHARACTERS_ON_ACCOUNT (premium) and buying 1 house for 1 character. This makes a number of free houses decresing very fast. Anyway, Elf made it that good that you can say the number of houses of which may be bought on 1 account and even disable it without recompilation. Great!

edit: Elf, how did you manage to keep 37h uptime?! After 4-5h with ~55 players online my server get stucked (C2D [email protected])
 
@Soul4soul - Maybe use commas, capitals and so?:p

@Elf - I don't really know if it should be >= by that what my mathematical instinct says to me. I don't know C++ that much. Yet :)

@Topic - The purpouse of this script is to avoid making MAX_ALLOWED_CHARACTERS_ON_ACCOUNT (premium) and buying 1 house for 1 character. This makes a number of free houses decresing very fast. Anyway, Elf made it that good that you can say the number of houses of which may be bought on 1 account and even disable it without recompilation. Great!

edit: Elf, how did you manage to keep 37h uptime?! After 4-5h with ~55 players online my server get stucked (C2D [email protected])
#offtopic:
I'm running 2 servers and a seperated login server. Last time it had 120 hours uptime.
 
:eek:

The server uses TFS "core"?

Yep.
I didn't add there that the servers are on one host, using one 'data/' directory and one database - my multiworld support :D
I am going to seperate game functions from loginserver and release it as TFS loginserver as I am now an official developer :p
 
Last edited:
This is really good, but not so good, but anyway, good job and thanks for releasing it!
 
Back
Top