local config = {
level = 1,
onlyPremium = true
}
function onSay(player, words, param)
local housePrice = configManager.getNumber(configKeys.HOUSE_PRICE)
if housePrice == -1 then
return true
end
if player:getLevel() < config.level then
player:sendCancelMessage("You need level " .. config.level .. " or higher to buy a house.")
return false
end
if config.onlyPremium and not player:isPremium() then
player:sendCancelMessage("You need a premium account.")
return false
end
local position = player:getPosition()
position:getNextPosition(player:getDirection())
local tile = Tile(position)
local house = tile and tile:getHouse()
if not house then
player:sendCancelMessage("You have to be looking at the door of the house you would like to buy.")
return false
end
if house:getOwnerGuid() > 0 then
player:sendCancelMessage("This house already has an owner.")
return false
end
if player:getHouse() then
player:sendCancelMessage("You are already the owner of a house.")
return false
end
-- Sprawdzenie wielkości domu i lidera gildii dla dużych domów
local tileCount = house:getTileCount()
if tileCount > 200 then -- limit dla dużych domów
local guild = player:getGuild()
if not guild or player:getGuildLevel() < 3 then -- 3 to poziom lidera gildii
player:sendCancelMessage("Only the guild leader can buy guild halls.")
return false
end
end
local price = tileCount * housePrice
if not player:removeTotalMoney(price) then
player:sendCancelMessage("You do not have enough money.")
return false
end
house:setOwnerGuid(player:getGuid())
player:sendTextMessage(MESSAGE_INFO_DESCR, "You have successfully bought this house, be sure to have the money for the rent in the bank.")
return false
end