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

Remove premium from !buyhouse command

Devhir

A bit of Everything
Joined
Jul 22, 2008
Messages
135
Reaction score
0
Hey guys im stumped, i speared every folder in my ot and checked every .lua file but i cannot find the script for !buyhouse command so i can remove premium from it. can anyone help me out?
 
What do you want exactly?
When you say !buyhouse the command will remove you X days of premium or the thing you want is that free players can use the command !buyhouse ?
 
you must in commands.cpp delete function isPremium or other with premium i dont no how function u have, after delete compiled and all;)
 
yes i want free player to use !buyhouse command and !createguild command. where do i find command.cpp im using tfs 8.21
 
jester, i got the sources, learned to compile just now lol, but the line is like this:

if(g_config.getString(ConfigManager::HOUSE_NEED_PREMIUM) != "yes" || player->isPremium())

if i put "no", will it work or?
 
I think it yes... but put more lines after this line to see the code.

Cos if you change that line to this if(g_config.getString(ConfigManager::HOUSE_NEED_PREMIUM) != "no" || player->isPremium()), it means that the player its FREE and it will buy the house as if he is a PREMIUM PLAYER, but if a premium player try to buy one i dunno what will happen...

Put the full code please.
 
Code:
		Position pos = player->getPosition();
		pos = getNextPosition(player->direction, pos);
		if(Tile* tile = g_game.getTile(pos.x, pos.y, pos.z))
		{
			if(HouseTile* houseTile = dynamic_cast<HouseTile*>(tile))
			{
				if(House* house = houseTile->getHouse())
				{
					if(house->getDoorByPosition(pos))
					{
						if(!house->getHouseOwner())
						{
							if(g_config.getString(ConfigManager::HOUSE_NEED_PREMIUM) != "no" || player->isPremium())
							{
								uint32_t levelToBuyHouse = g_config.getNumber(ConfigManager::LEVEL_TO_BUY_HOUSE);
								if(player->getLevel() >= levelToBuyHouse)
								{
									if(house->getPrice())
									{
										if(g_game.getMoney(player) >= house->getPrice() && g_game.removeMoney(player, house->getPrice()))
										{
											house->setHouseOwner(player->guid);
											player->sendTextMessage(MSG_INFO_DESCR, "You have successfully bought this house, remember to leave money at bank or depot of this city for rent.");
											return true;
										}
										else
											player->sendCancel("You do not have enough money.");

Here it is, not full but full will tkae up the whole page lol.
 
Hello!

I have this in my sources (commands.cpp):
bool Commands::buyHouse(Creature* creature, const std::string& cmd, const std::string& param)
{
Player* player = creature->getPlayer();
if(player)
{
Position pos = player->getPosition();
pos = getNextPosition(player->direction, pos);
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;
}
}
if(Tile* tile = g_game.getTile(pos.x, pos.y, pos.z))
{
if(HouseTile* houseTile = dynamic_cast<HouseTile*>(tile))
{
if(House* house = houseTile->getHouse())
{
if(house->getDoorByPosition(pos))
{
if(!house->getHouseOwner())
{
if(player->isPremium())
{
uint32_t price = 0;
for(HouseTileList::iterator it = house->getHouseTileBegin(); it != house->getHouseTileEnd(); it++)
price += g_config.getNumber(ConfigManager::HOUSE_PRICE);
if(price)
{
uint32_t money = g_game.getMoney(player);
if(money >= price && g_game.removeMoney(player, price))
{
house->setHouseOwner(player->guid);
player->sendTextMessage(MSG_INFO_DESCR, "You have successfully bought this house, be sure to have the money for the rent in your depot of this city.");
return true;
}
else
player->sendCancel("You do not have enough money.");
}
else
player->sendCancel("That house doesn't contain any house tile.");
}
else
player->sendCancelMessage(RET_YOUNEEDPREMIUMACCOUNT);
}

else
player->sendCancel("This house alreadly has an owner.");
}
else
player->sendCancel("You have to be looking at the door of the house you would like to buy.");
}
else
player->sendCancel("You have to be looking at the door of the house you would like to buy.");
}
else
player->sendCancel("You have to be looking at the door of the house you would like to buy.");
}
else
player->sendCancel("You have to be looking at the door of the house you would like to buy.");
}
return false;
}

So you must remove the lines are marked in BOLD.

Later, it must be like this:
bool Commands::buyHouse(Creature* creature, const std::string& cmd, const std::string& param)
{
Player* player = creature->getPlayer();
if(player)
{
Position pos = player->getPosition();
pos = getNextPosition(player->direction, pos);
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;
}
}
if(Tile* tile = g_game.getTile(pos.x, pos.y, pos.z))
{
if(HouseTile* houseTile = dynamic_cast<HouseTile*>(tile))
{
if(House* house = houseTile->getHouse())
{
if(house->getDoorByPosition(pos))
{
if(!house->getHouseOwner())
{
uint32_t price = 0;
for(HouseTileList::iterator it = house->getHouseTileBegin(); it != house->getHouseTileEnd(); it++)
price += g_config.getNumber(ConfigManager::HOUSE_PRICE);
if(price)
{
uint32_t money = g_game.getMoney(player);
if(money >= price && g_game.removeMoney(player, price))
{
house->setHouseOwner(player->guid);
player->sendTextMessage(MSG_INFO_DESCR, "You have successfully bought this house, be sure to have the money for the rent in your depot of this city.");
return true;
}
else
player->sendCancel("You do not have enough money.");
}
else
player->sendCancel("That house doesn't contain any house tile.");
}
else
player->sendCancel("This house alreadly has an owner.");
}
else
player->sendCancel("You have to be looking at the door of the house you would like to buy.");
}
else
player->sendCancel("You have to be looking at the door of the house you would like to buy.");
}
else
player->sendCancel("You have to be looking at the door of the house you would like to buy.");
}
else
player->sendCancel("You have to be looking at the door of the house you would like to buy.");
}
return false;
}

Bye!
 
Last edited:
thnx, when compiling im gettin errors such as:

Code:
1665 C:\Documents and Settings\Kingcool\Desktop\Forgotten Sources\trunk\commands.cpp a function-definition is not allowed here before '{' token

1715 C:\Documents and Settings\Kingcool\Desktop\Forgotten Sources\trunk\commands.cpp expected `}' at end of input

ON

Code:
bool Commands::changeFloor(Creature* creature, const std::string &cmd, const std::string &param)
{ <----Error on this line
	Player* player = creature->getPlayer();


Any ideas?
 
Ok, I think now it will work...

The commands.cpp I'm going to pass you can not be open with Notepad, you must use Notepad+++, ok? But it will work correctly with the Dev-C++ compiler. :thumbup:
 

Attachments

thnx dude, its hopeless tho, its either i am compiling wrong or im using wrong method to compile coz i got the same error messages. Dam, gonna be hard without these 2 functions on server especially guilds -.-

I am using this method:
http://otland.net/f137/tutorial-how-compile-forgotten-server-latest-sources-166/

If your using another please let me know of it. Or can you compile these files for me and then upload. My only hope now.
 
Dunno... I done the source code, cos u had a { before a function.
I solved this problem... and now I dunno if u have the same problem.
 
Back
Top