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

Lua How to show how many tiles there is in the house on look the door

maikons

Member
Joined
Aug 1, 2015
Messages
227
Reaction score
16
How to show how many tiles there is in the house on look the door, just like in this img:

dEl0Soz.png


With some help from people from this forum i changed:
Code:
void House::updateDoorDescription(std::string _name/* = ""*/)

From:
Fir3element/3777 (https://github.com/Fir3element/3777/blob/master/src/house.cpp)

To:
Code:
void House::updateDoorDescription(std::string _name/* = ""*/)
{
    int32_t house_tiles = (price / g_config.getNumber(ConfigManager::HOUSE_PRICE));
    std::string tmp = "house";
    if(isGuild())
        tmp = "hall";

    char houseDescription[200];
    if(owner)
    {
        if(isGuild())
            IOGuild::getInstance()->getGuildById(_name, owner);
        else if(_name.empty())
            IOLoginData::getInstance()->getNameByGuid(owner, _name);

        sprintf(houseDescription, "It belongs to %s '%s'. %s owns this %s. It has %d tiles.", tmp.c_str(), name.c_str(), _name.c_str(), tmp.c_str(), house_tiles);
    }
    else
        sprintf(houseDescription, "It belongs to %s '%s'. Nobody owns this %s. It costs %d gold coins. It has %d tiles.", tmp.c_str(), name.c_str(), tmp.c_str(), price, house_tiles);

    for(HouseDoorList::iterator it = doorList.begin(); it != doorList.end(); ++it)
        (*it)->setSpecialDescription(houseDescription);
}

But it's not working 100%


its only working with houses who had iteract with players
if some player had !buyhouse, !leavehouse, !sellhouse, it is showing right:
Code:
It belongs to house 'Unnamed House #1'. Maikao owns this house. It has 39 tiles.
Code:
It belongs to house 'Unnamed House #1'. Nobody owns this house. It costs 3900000 gold coins. It has 39 tiles.





But houses who players never had buy or sell, never interact, it's not showing how many tiles the house have (if a player buy the house it starts to shows)
Code:
It belongs to house 'Unnamed House #3'. Nobody owns this house. It costs 2500000 gold coins.



how to fix it?
 
Hello there,

as you can see the name of the function is updateDoorDescription, which is called only after someone interacts with them, in order to fix this problem you could call the function as soon as the server starts.

Best Wishes,
Okke
 
Hello there,

as you can see the name of the function is updateDoorDescription, which is called only after someone interacts with them, in order to fix this problem you could call the function as soon as the server starts.

Best Wishes,
Okke

I don't find another function to deal with this in no where

And looks like be the only one cause, always when add a house should update the door desc:
Code:
void House::addDoor(Door* door)
{
    door->addRef();
    doorList.push_back(door);

    door->setHouse(this);
    updateDoorDescription();
}

Where did u found the other function, the start one?
 
Maybe the addDoor function was only called when you first ran the house into the server and it was saved?
Can you try calling updateDoorDescription function everytime the server starts?
Idk where or how you can do it, I'm c++ noob.
 
bro i already put the part of code and its working directly
this:

Are u sure? are u using this 0.4 source code?

I tried yours:

And gave me this errors:
Code:
CC       = g++
house.cpp:150:6: error: prototype for ‘void House::updateDoorDescription(std::__cxx11::string, Door*)’ does not match any in class ‘House’
 void House::updateDoorDescription(std::string _name/* = ""[I]/, Door[/I] door/* = NULL*/)
      ^~~~~
In file included from house.cpp:18:0:
house.h:218:8: error: candidate is: void House::updateDoorDescription(std::__cxx11::string)
   void updateDoorDescription(std::string _name = "");
        ^~~~~~~~~~~~~~~~~~~~~
Makefile:33: recipe for target 'house.o' failed
line 150 is the updateDoorDescription...

My updateDoorDescription was:
Code:
void House::updateDoorDescription(std::string _name/* = ""*/)
{
    int32_t house_tiles = (price / g_config.getNumber(ConfigManager::HOUSE_PRICE));
    std::string tmp = "house";
    if(isGuild())
        tmp = "hall";

    char houseDescription[200];
    if(owner)
    {
        if(isGuild())
            IOGuild::getInstance()->getGuildById(_name, owner);
        else if(_name.empty())
            IOLoginData::getInstance()->getNameByGuid(owner, _name);

        sprintf(houseDescription, "It belongs to %s '%s'. %s owns this %s. It has %d tiles.", tmp.c_str(), name.c_str(), _name.c_str(), tmp.c_str(), house_tiles);
    }
    else
        sprintf(houseDescription, "It belongs to %s '%s'. Nobody owns this %s. It costs %d gold coins. It has %d tiles.", tmp.c_str(), name.c_str(), tmp.c_str(), price, house_tiles);

    for(HouseDoorList::iterator it = doorList.begin(); it != doorList.end(); ++it)
        (*it)->setSpecialDescription(houseDescription);
}
 
Tried to use yours:
Code:
void updateDoorDescription(std::string _name = "", Door* door = NULL);

Code:
void House::updateDoorDescription(std::string _name/* = ""[I]/, Door[/I] door/* = NULL*/)
{
    int32_t house_tiles = (price / g_config.getNumber(ConfigManager::HOUSE_PRICE));
    std::string tmp = "house";
    if(isGuild())
        tmp = "hall";
 
    char houseDescription[250];
    if(owner)
    {
        if(isGuild())
            IOGuild::getInstance()->getGuildById(_name, owner);
        else if(_name.empty())
            IOLoginData::getInstance()->getNameByGuid(owner, _name);
 
        sprintf(houseDescription, "It belongs to %s '%s'. %s owns this %s. It has %d tiles.", tmp.c_str(), name.c_str(), _name.c_str(), tmp.c_str(), house_tiles);
    }
    else
        sprintf(houseDescription, "It belongs to %s '%s'. Nobody owns this %s. It costs %d gold coins. It has %d tiles.", tmp.c_str(), name.c_str(), tmp.c_str(), price, house_tiles);
 
    if(!door)
    {
        for(HouseDoorList::iterator it = doorList.begin(); it != doorList.end(); ++it)
            (*it)->setSpecialDescription(houseDescription);
    }
    else
        door->setSpecialDescription(houseDescription);
}

Code:
player.o: In function `Player::manageAccount(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)':
player.cpp:(.text+0x95b9): undefined reference to `House::updateDoorDescription(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >)'
configmanager.o: In function `ConfigManager::reload()':
configmanager.cpp:(.text+0x471b): undefined reference to `House::updateDoorDescription(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >)'
iomapserialize.o: In function `IOMapSerialize::loadMap(Map*)':
iomapserialize.cpp:(.text+0x3dd6): undefined reference to `House::updateDoorDescription(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >)'
collect2: error: ld returned 1 exit status
Makefile:37: recipe for target 'tfs' failed
make: *** [tfs] Error 1




My was:
Code:
void updateDoorDescription(std::string _name = "");

Code:
void House::updateDoorDescription(std::string _name/* = ""*/)
{
    int32_t house_tiles = (price / g_config.getNumber(ConfigManager::HOUSE_PRICE));
    std::string tmp = "house";
    if(isGuild())
        tmp = "hall";

    char houseDescription[200];
    if(owner)
    {
        if(isGuild())
            IOGuild::getInstance()->getGuildById(_name, owner);
        else if(_name.empty())
            IOLoginData::getInstance()->getNameByGuid(owner, _name);

        sprintf(houseDescription, "It belongs to %s '%s'. %s owns this %s. It has %d tiles.", tmp.c_str(), name.c_str(), _name.c_str(), tmp.c_str(), house_tiles);
    }
    else
        sprintf(houseDescription, "It belongs to %s '%s'. Nobody owns this %s. It costs %d gold coins. It has %d tiles.", tmp.c_str(), name.c_str(), tmp.c_str(), price, house_tiles);

    for(HouseDoorList::iterator it = doorList.begin(); it != doorList.end(); ++it)
        (*it)->setSpecialDescription(houseDescription);
}
 
Back
Top