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

maikons

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



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?
 

Okke

Voidcore 7.4
Joined
Jul 19, 2015
Messages
926
Best answers
19
Reaction score
430
Location
germany
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
 
OP
M

maikons

Member
Joined
Aug 1, 2015
Messages
199
Best answers
0
Reaction score
13
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?
 

namco

Alienbutserious
Joined
Sep 5, 2010
Messages
128
Best answers
2
Reaction score
33
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.
 

Znote

<?php echo $title; ?>
Staff member
Global Moderator
Premium User
Joined
Feb 14, 2008
Messages
6,667
Best answers
202
Reaction score
1,375
Location
Norway, Oslo
Clean the house database is it?

You have to clean the house_auctions table before you remove the houses. Would be weird to auction away houses that theoretically don't exist anymore. :p
 
OP
M

maikons

Member
Joined
Aug 1, 2015
Messages
199
Best answers
0
Reaction score
13
You have to clean the house_auctions table before you remove the houses. Would be weird to auction away houses that theoretically don't exist anymore. :p
I'm already tried
I can't even delete it


 
OP
M

maikons

Member
Joined
Aug 1, 2015
Messages
199
Best answers
0
Reaction score
13
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);
}
 
OP
M

maikons

Member
Joined
Aug 1, 2015
Messages
199
Best answers
0
Reaction score
13
Im using otx 2.9 but is based on 0.4
Idk a shit, but i thikn if i use yours updateDoorDescription from house.h it could work

how is your updateDoorDescription on houses.h?
 
OP
M

maikons

Member
Joined
Aug 1, 2015
Messages
199
Best answers
0
Reaction score
13
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);
}
 
Top