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

Solved Tfs 0.4 r3777 - houses problem

Nekiro

Legendary OT User
TFS Developer
Joined
Sep 7, 2015
Messages
2,686
Solutions
127
Reaction score
2,134
Hello, I have problem with tfs 0.4, cline 8.6. I have very weird error, when im trying to buy house by command !buyhouse, it;s not working it says:
58143c84b85078e1bcd4aed81d13bd2b.png


And another error its that when I make new house doors dont work. It says only "closed door".

And one question maybe someone have auction houses script for tfs 0.4?
 
Show us your script

Edit: your script most likely doesn't check the direction/lookpos. Try something like this:

Code:
function onSay(cid, words, param)
    local lookPos = getPlayerLookPos(cid) -- This wasn't either added or functioning properly in your script
    local house = House.getHouseByPos(lookPos)
    if(house == nil) then
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You must be looking at a house to buy one.")
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_RED, words)
        return false
    end

    if(house:buy(cid)) then
        doSendMagicEffect(getThingPos(cid), CONST_ME_MAGIC_BLUE)
    else
        doSendMagicEffect(getThingPos(cid), CONST_ME_POFF)
    end

    doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_RED, words)
    return false
end
 
Last edited:
Maybe try with normal (not god) account?
Not working with normal too.

Show us your script

Edit: your script most likely doesn't check the direction/lookpos. Try something like this:

Code:
function onSay(cid, words, param)
    local lookPos = getPlayerLookPos(cid) -- This wasn't either added or functioning properly in your script
    local house = House.getHouseByPos(lookPos)
    if(house == nil) then
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You must be looking at a house to buy one.")
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_RED, words)
        return false
    end

    if(house:buy(cid)) then
        doSendMagicEffect(getThingPos(cid), CONST_ME_MAGIC_BLUE)
    else
        doSendMagicEffect(getThingPos(cid), CONST_ME_POFF)
    end

    doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_RED, words)
    return false
end

Thank you, i tried your script and its weird cause its not even executing. Its like normal word when I write command "!buyhouse".

My script is in source like that:
Talkactions.xml: <talkaction words="alevo grav;!buyhouse" filter="word-spaced" event="function" value="houseBuy"/>

and in source:

Code:
bool TalkAction::houseBuy(Creature* creature, const std::string&, const std::string&)
{
    Player* player = creature->getPlayer();
    if (!player || !g_config.getBool(ConfigManager::HOUSE_BUY_AND_SELL))
        return false;

    const Position& pos = getNextPosition(player->getDirection(), player->getPosition());
    Tile* tile = g_game.getTile(pos);
    if (!tile)
    {
        player->sendCancel("You have to be looking at door of flat you would like to purchase.");
        g_game.addMagicEffect(player->getPosition(), MAGIC_EFFECT_POFF);
        return false;
    }

    HouseTile* houseTile = tile->getHouseTile();
    if (!houseTile)
    {
        player->sendCancel("You have to be looking at door of flat you would like to purchase.");
        g_game.addMagicEffect(player->getPosition(), MAGIC_EFFECT_POFF);
        return false;
    }

    House* house = houseTile->getHouse();
    if (!house)
    {
        player->sendCancel("You have to be looking at door of flat you would like to purchase.");
        g_game.addMagicEffect(player->getPosition(), MAGIC_EFFECT_POFF);
        return false;
    }

    if (!house->getDoorByPosition(pos))
    {
        player->sendCancel("You have to be looking at door of flat you would like to purchase.");
        g_game.addMagicEffect(player->getPosition(), MAGIC_EFFECT_POFF);
        return false;
    }

    if (!house->isGuild())
    {
        if (Houses::getInstance()->getHouseByPlayerId(player->getGUID()))
        {
            player->sendCancel("You already rent another house.");
            g_game.addMagicEffect(player->getPosition(), MAGIC_EFFECT_POFF);
            return false;
        }

        uint16_t accountHouses = g_config.getNumber(ConfigManager::HOUSES_PER_ACCOUNT);
        if (accountHouses > 0 && Houses::getInstance()->getHousesCount(player->getAccount()) >= accountHouses)
        {
            char buffer[80];
            sprintf(buffer, "You may own only %d house%s per account.", accountHouses, (accountHouses != 1 ? "s" : ""));

            player->sendCancel(buffer);
            g_game.addMagicEffect(player->getPosition(), MAGIC_EFFECT_POFF);
            return false;
        }

        if (g_config.getBool(ConfigManager::HOUSE_NEED_PREMIUM) && !player->isPremium())
        {
            player->sendCancelMessage(RET_YOUNEEDPREMIUMACCOUNT);
            g_game.addMagicEffect(player->getPosition(), MAGIC_EFFECT_POFF);
            return false;
        }

        uint32_t levelToBuyHouse = g_config.getNumber(ConfigManager::LEVEL_TO_BUY_HOUSE);
        if (player->getLevel() < levelToBuyHouse)
        {
            char buffer[90];
            sprintf(buffer, "You have to be at least Level %d to purchase a house.", levelToBuyHouse);
            player->sendCancel(buffer);
            g_game.addMagicEffect(player->getPosition(), MAGIC_EFFECT_POFF);
            return false;
        }
    }
    else
    {
        if (!player->getGuildId() || player->getGuildLevel() != GUILDLEVEL_LEADER)
        {
            player->sendCancel("You have to be at least a guild leader to purchase a hall.");
            g_game.addMagicEffect(player->getPosition(), MAGIC_EFFECT_POFF);
            return false;
        }

        if (Houses::getInstance()->getHouseByGuildId(player->getGuildId()))
        {
            player->sendCancel("Your guild rents already another hall.");
            g_game.addMagicEffect(player->getPosition(), MAGIC_EFFECT_POFF);
            return false;
        }
    }

    if (house->getOwner())
    {
        player->sendCancel("This flat is already owned by someone else.");
        g_game.addMagicEffect(player->getPosition(), MAGIC_EFFECT_POFF);
        return false;
    }

    if ((uint32_t)g_game.getMoney(player) < house->getPrice() || !g_game.removeMoney(player, house->getPrice()))
    {
        player->sendCancel("You do not have enough money.");
        g_game.addMagicEffect(player->getPosition(), MAGIC_EFFECT_POFF);
        return false;
    }

    house->setOwnerEx(player->getGUID(), true);
    std::string ret = "You have successfully bought this ";
    if (house->isGuild())
        ret += "hall";
    else
        ret += "house";

    ret += ", remember to leave money at ";
    if (house->isGuild())
        ret += "guild owner ";

    if (g_config.getBool(ConfigManager::BANK_SYSTEM))
        ret += "bank or ";

    ret += "depot of this town for rent.";
    player->sendTextMessage(MSG_INFO_DESCR, ret.c_str());

    g_game.addMagicEffect(player->getPosition(), MAGIC_EFFECT_WRAPS_BLUE);
    return false;
}
 
Not working with normal too.



Thank you, i tried your script and its weird cause its not even executing. Its like normal word when I write command "!buyhouse".
Probably wrong onSay function (not up-to date). Please post your script here
 
Check post again.

Show us your script

Edit: your script most likely doesn't check the direction/lookpos. Try something like this:

Code:
function onSay(cid, words, param)
    local lookPos = getPlayerLookPos(cid) -- This wasn't either added or functioning properly in your script
    local house = House.getHouseByPos(lookPos)
    if(house == nil) then
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You must be looking at a house to buy one.")
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_RED, words)
        return false
    end

    if(house:buy(cid)) then
        doSendMagicEffect(getThingPos(cid), CONST_ME_MAGIC_BLUE)
    else
        doSendMagicEffect(getThingPos(cid), CONST_ME_POFF)
    end

    doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_RED, words)
    return false
end
[17:23:52.463] [Error - TalkAction Interface]
[17:23:52.463] data/talkactions/scripts/house.lua:eek:nSay
[17:23:52.463] Description:
[17:23:52.463] data/talkactions/scripts/house.lua:3: attempt to index global 'house' (a nil value)
[17:23:52.464] stack traceback:
[17:23:52.464] data/talkactions/scripts/house.lua:3: in function <data/talkactions/scripts/house.lua:1>
 
Check post again.


[17:23:52.463] [Error - TalkAction Interface]
[17:23:52.463] data/talkactions/scripts/house.lua:eek:nSay
[17:23:52.463] Description:
[17:23:52.463] data/talkactions/scripts/house.lua:3: attempt to index global 'house' (a nil value)
[17:23:52.464] stack traceback:
[17:23:52.464] data/talkactions/scripts/house.lua:3: in function <data/talkactions/scripts/house.lua:1>
I don't believe that the problem is the talkaction, the door position of houses are not correct or the tile of the door is not a house tile I believe (not 100% sure as I am not a mapper and never used RME)
 
make sure your door has door ID 1 and that it is house tile

sample from hause.xml from map editor
Code:
<house name="Halsey St. 5D" houseid="172" entryx="1297" entryy="1051" entryz="5" rent="0" townid="1" size="28"/>

but in map editor my all doors in houses have door ID :0
Post automatically merged:

make sure your door has door ID 1 and that it is house tile
You have right but why my all house have 0 ID.

Do I have to change all ID manually??
maybe there is another way?
 
Last edited:
Back
Top