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

Feature [1.x] Buy house with gold ingot as example

Marko999x

999x era
Premium User
Joined
Dec 14, 2017
Messages
2,825
Solutions
82
Reaction score
1,947
Location
Germany
Since I couldn't really find a thread about it I just release it to avoid people creating 100 threads about it xD

house.cpp
line 124:
Lua:
it->setSpecialDescription(fmt::format("It belongs to house '{:s}'. {:s} owns this house.{:s}", houseName, (owner != 0) ? ownerName : "Nobody", g_config.getBoolean(ConfigManager::HOUSE_DOOR_SHOW_PRICE) && (housePrice != -1) && (owner == 0) ? fmt::format(" It costs {:d} gold coins.", (houseTiles.size() * housePrice)) : ""));

Lua:
It costs {:d} gold coins

change it to gold ingot as example

Lua:
It costs {:d} gold ingot

now open your buyhouse.lua which is placed in data/talkactions

line 39:
Lua:
if not player:removeMoney(price) then

change it to

Lua:
if not player:removeItem(9971, price) then

( 9971 is gold ingot )

and in config.lua you can setup the price as you want :D thats it

Sorry that I had to use "feature" im not sure if its right lol
 
Last edited:
I needed that... Wait a minute... I would like to know if it's possible to buy this Gold Ingot only where there are giant houses/guilds using this currency. And in other houses, would it still be possible to use regular Gold Coins? Is it possible to separate the two?
 
I needed that... Wait a minute... I would like to know if it's possible to buy this Gold Ingot only where there are giant houses/guilds using this currency. And in other houses, would it still be possible to use regular Gold Coins? Is it possible to separate the two?

Untested but should work
C++:
it->setSpecialDescription(fmt::format("It belongs to house '{:s}'. {:s} owns this house.{:s}", houseName, (owner != 0) ? ownerName : "Nobody", g_config.getBoolean(ConfigManager::HOUSE_DOOR_SHOW_PRICE) && (housePrice != -1) && (owner == 0) ? fmt::format(" It costs {:d} gold {:s}.", (houseTiles.size() * housePrice), (houseTiles.size() >= 100) ? "ingots" : "coins") : ""));

and then change:
Lua:
local price = house:getTileCount() * housePrice
if not player:removeTotalMoney(price) then
    player:sendCancelMessage("You do not have enough money.")
    return false
end
to
Lua:
local size = house:getTileCount()
local price = size * housePrice
if (size >= 100 and not player:removeItem(9971, price)) or (size < 100 and not player:removeTotalMoney(price)) then
    player:sendCancelMessage(("You do not have enough %s."):format(size >= 100 and "ingots" or "coins"))
    return false
end
 
Last edited:
Untested but should work
This GH cost 326000 Gold Ingots. I want this Giant House to cost only 500 Gold Ingots, yes, it depends on each different Giant House what I want to set, understand? And don't use Gold Coins. Okay, for other normal houses without being giant houses, they can charge the standard Gold Coins based on the normal size agreement.

Lua:
22:07 You see a closed door.
It belongs to house 'teste'. Nobody owns this house. It costs 326000 gold ingots.
ID do Item: 8547
Posição: 971, 1017, 7
 
This GH cost 326000 Gold Ingots. I want this Giant House to cost only 500 Gold Ingots, yes, it depends on each different Giant House what I want to set, understand? And don't use Gold Coins. Okay, for other normal houses without being giant houses, they can charge the standard Gold Coins based on the normal size agreement.

Lua:
22:07 You see a closed door.
It belongs to house 'teste'. Nobody owns this house. It costs 326000 gold ingots.
ID do Item: 8547
Posição: 971, 1017, 7
Well you can change the formula however you want. You can see in both places its checking size >= 100 to determine nuggets or gp. And then its houseTiles * pricePerTile(in config) to determine the price. You can edit both of these yourself.

If you want individual prices set on specific houses, then you can do this a few ways:
A) Make a lua based system, keep a table of prices(id => price) and then grab the price in buyhouse.lua, and change the door descriptions from sources to lua (using onLook callback).

B) You will need to edit RME sources to set house prices, and then read the new attribute during houses deserialization in the server sources. Then you can edit the description using the new price, or default using current formula. You can then make a new lua method such as house:getPrice() and so on....
Post automatically merged:

If you want to hardcode it to 5 nuggets per tile (if >=100sqm):
C++:
it->setSpecialDescription(fmt::format("It belongs to house '{:s}'. {:s} owns this house.{:s}", houseName, (owner != 0) ? ownerName : "Nobody", g_config.getBoolean(ConfigManager::HOUSE_DOOR_SHOW_PRICE) && (housePrice != -1) && (owner == 0) ? fmt::format(" It costs {:d} gold {:s}.", (houseTiles.size() >= 100) ? houseTiles.size() * 5 : houseTiles.size() * housePrice, (houseTiles.size() >= 100) ? "ingots" : "coins") : ""));

Lua:
local nuggetPerTile = 5
local size = house:getTileCount()
local price = size >= 100 and (size * nuggetPerTile) or (size * housePrice)
if (size >= 100 and not player:removeItem(9971, price)) or (size < 100 and not player:removeTotalMoney(price)) then
    player:sendCancelMessage(("You do not have enough %s."):format(size >= 100 and "ingots" or "coins"))
    return false
end
 
Last edited:
Back
Top