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

Only guild lider can to buy

Ciosny

Member
Joined
Aug 16, 2024
Messages
116
Solutions
1
Reaction score
15
Hi! :)
How can I change it so that only the Guild Leader can buy the Guild Hall?

By the way, on the GH map they are marked as GH, but in the game they are called "House" by clicking look on the door and any player who is not the guild leader can buy a guild hall

"It belongs to house 'Riverspring'. Nobody owns this house. It costs 448000 gold coins. Item ID: 1221"

TFS 1.4.2, 10.98 otcv8
 
easiest way you could do it would probably be to query how many tiles the house have. Ideally guild houses should be large over 100sqm :)
Just an idea.
 
First check if u have column "type" in house table, then make simple logic depends of which type house is and check if bidding/buyer character is leader of the guild.
 
First check if u have column "type" in house table, then make simple logic depends of which type house is and check if bidding/buyer character is leader of the guild.
"Type in house table"
do you mean on the map editor?

Everywhere on the door is marked "Guild Hall"
 
sql database
Now I noticed that I do not have information about guild hall added in the table sql database 🧐
Post automatically merged:

And in src I don't have the "guild hall" interpreted and the division of "guild hall" and "house"
 
Last edited:
sql database
house.xml:
<house name="Riverspring" houseid="1038" entryx="32761" entryy="32128" entryz="7" rent="19450" guildhall="true" townid="3" size="284" />
In game:
It belongs to house 'Riverspring'. Nobody owns this house. It costs 448000 gold coins.

(someone who is not a guild leader can buy a guild house)


What table should I add to SQL to make GH available only to the guild leader?

And the second question, shouldn't I edit src for it to work?
 

Attachments

SOLVED

I managed to make the entire script. I'm putting it here, maybe someone will find it useful :)

Maybe it can be done differently, but the important thing is that it works.

I noticed another problem with !leavehouse but I will create a new topic for it

Script:

LUA:
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
 
Back
Top