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

Kick from house if player doesn't have premium

elf

Sing, sing blue silver
Senator
Joined
Dec 11, 2007
Messages
3,667
Solutions
1
Reaction score
129
Location
Warsaw, Poland
GitHub
tayandenga
Twitch
tayandenga
As I heard (slawkens told so KaczooH) - if premium ends, player still has his house.
I wrote a little modification, which instead of taking cash, will remove non-premium player from his house while taking rent for it (of course it sends items to depo!).
Morever, I did it configurable from config.lua - exactly: does the player need premium to own and buy a house (Thanks KaczooH for request)

1. Open house.cpp, and find (about line 844):
Code:
Depot* depot = player->getDepot(town->getTownID(), true);
bool savePlayerHere = true;
Replace it with:
Code:
			bool savePlayerHere = true;
			// [START] Manual
			bool playerHasPremium = true;
			if (g_config.getString(ConfigManager::HOUSE_NEED_PREMIUM) == "yes" && !player->isPremium())
				playerHasPremium = false;
			if (playerHasPremium)
			{
			// [PAUSE] Manual
				Depot* depot = player->getDepot(town->getTownID(), true); //Moved
Still, in house.cpp find (about line 911):
Code:
if(!player->isOnline())
{
if(savePlayerHere)
IOLoginData.savePlayer(player, true);
delete player;
}
Add above it:
Code:
			// [CONTINUE] Manual
			}
			else
			{
				house->setHouseOwner(0);
				savePlayerHere = false;
			}
			// [END] Manual
Save and close the file.

2. Open commands.cpp, and find (line 853):
Code:
if(!tradePartner->isPremium())
Replace it with:
Code:
if(g_config.getString(ConfigManager::HOUSE_NEED_PREMIUM) == "yes" && !tradePartner->isPremium()) //Changed manually
Still, in commands.cpp find (about line 938 in Commands::buyHouse):
Code:
if(player->isPremium())
Replace it with:
Code:
if(g_config.getString(ConfigManager::HOUSE_NEED_PREMIUM) != "yes" || player->isPremium()) //Changed manually
Save and close the file.

3. Open configmanager.cpp, and find (line 132):
Code:
	m_confString[GENERATE_ACCOUNT_NUMBER] = getGlobalString(L, "generateAccountNumber", "yes");
Add after it:
Code:
	m_confString[HOUSE_NEED_PREMIUM] = getGlobalString(L, "premiumToOwnHouse", "yes"); //Added by Elf
Save and close the file.

4. Open configmanager.h, and find (line 83):
Code:
			GENERATE_ACCOUNT_NUMBER,
Add after it:
Code:
			HOUSE_NEED_PREMIUM, //Added manually
Save and close the file.

Now compile the server.


EDIT: Few pro coders may say its useless, 'Cause as far as I ... think so :p 'kick from a house if player doesn't have premium' may be done in iologindata.cpp, while player does login on the server - BUT
I wanted to make it more realistic, not comparing to Tibian system (where cipsoft counts their cash from premium and so :D).
Example:
Rent period is set to week, and which buys a house has 8 days of premium.
After a week, he pays for the house, and next day losses premium priviligages.
#
If I would make it as in Tibia, player would just lose his gold - here, he has the house untill he paid for it (6 days more in the example).
Conclusion: Its more player friendly ;)
 
Last edited:
Great as always! Rep++
For MANY rpg servers it's very useful!
It also solve a problem of "all houses rented" in some way. If premium ends, player is kicked. Great!!!

@slawkens - report it Tala to include it into official sources - if somebody doesn't need it can just simply turn it off.
 

Similar threads

Back
Top