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

[7.6] Widoczna cena domków.

Dawcio92

New Member
Joined
Sep 9, 2019
Messages
31
Reaction score
0
Witam,
jak w kodzie poniżej można zrobić, aby po kliknięciu na drzwi, widoczna będzie cena domków?
Pozdrawiam!

C++:
else if (text == "!buyhouse" && g_config.getGlobalString("buyhouse") == "yes")
{
  unsigned long money = player->getMoney();
  bool last = false;
  for (int x = player->pos.x-1; x <= player->pos.x+1 && !last; x++)
  {
   for(int y = player->pos.y-1; y <= player->pos.y+1 && !last; y++)
   {
    Position doorPos(x, y, player->pos.z);
    Tile* tile = getTile(doorPos);
    House* house = tile? tile->getHouse() : NULL;
    
    if (player->mmo > 0) {
       player->sendMagicEffect(player->pos, NM_ME_PUFF);
       player->sendTextMessage(MSG_SMALLINFO, "You must wait 5 seconds to use this command.");
    }
    if (player->mmo == 0 )
    {
                    char buf[128];
    
    if (house && house->getPlayerRights(player->getName()) == HOUSE_OWNER){
              player->sendTextMessage(MSG_BLUE_TEXT, "You own this house.");
              player->mmo += 5;
              return;
    }
    if (house && player->level < g_config.LEVEL_HOUSE){
              player->sendTextMessage(MSG_BLUE_TEXT, "You need higher level to buy house.");
              player->mmo += 5;
              return;
    }
    if (house && house->isBought()){
              player->sendTextMessage(MSG_BLUE_TEXT, "This house already has an owner.");
              player->mmo += 5;
              return;
    }
    if(house && house->checkHouseCount(player) >= g_config.getGlobalNumber("maxhouses", 0)){
              std::stringstream textmsg;
              textmsg << " You cant have more than " << g_config.getGlobalNumber("maxhouses", 1) << " houses ";
              player->sendTextMessage(MSG_BLUE_TEXT, textmsg.str().c_str());
              return;   
    }
    if (house && house->getPlayerRights(doorPos, player->getName()) == HOUSE_NONE && !house->isBought() && house->checkHouseCount(player) < g_config.getGlobalNumber("maxhouses", 1))
    {
     Item *item = dynamic_cast<Item*>(tile->getThingByStackPos(tile->getThingCount()-1));
     long price = g_config.getGlobalNumber("priceforsqm", 0) * house->getHouseSQM(house->getName());
     if (item && Item::items[item->getID()].isDoor && price <= money)
     {
      player->substractMoney(price);
      house->setOwner(player->getName());
      house->save();
      player->sendTextMessage(MSG_BLUE_TEXT, "You bought a house.");
      player->mmo += 5;
      last = true;
     }
     else
     {
     player->sendMagicEffect(player->pos, NM_ME_PUFF);
     player->sendTextMessage(MSG_BLUE_TEXT, "You dont have enough money to buy this house.");
     player->mmo += 5;
     }
   }
  }
 }
}
}
 
check in your config.lua and add this :

houseRentAsPrice = true - Should house prices be rent?

housePriceAsRent = false - Should the rental price be the price of the house?

housePriceEachSquare = 1000 - Price for each sqm of the house

houseRentPeriod = "monthly" - Rental billing period.
 
Znalazłem jeszcze coś takiego. Wydaję mi się, że tu można to zrobić (po kliknięciu widać cenę domku).

C++:
std::string House::getDescription() const
{
    std::stringstream doortext;
    doortext << "You see a door.\n It belongs to house '" << name << "'.\n " <<
        (owner.empty()? "Nobody" : owner) << " owns this house.";   
    return doortext.str();
}
 
Znalazłem jeszcze coś takiego. Wydaję mi się, że tu można to zrobić (po kliknięciu widać cenę domku).

C++:
std::string House::getDescription() const
{
    std::stringstream doortext;
    doortext << "You see a door.\n It belongs to house '" << name << "'.\n " <<
        (owner.empty()? "Nobody" : owner) << " owns this house."
    return doortext.str();
}

Spróbuj:
Code:
std::string House::getDescription() const
{
    long price = g_config.getGlobalNumber("priceforsqm", 0) * getHouseSQM(getName());

    std::stringstream doortext;
    doortext << "You see a door.\n It belongs to house '" << name << "'.\n " <<
        (owner.empty()? "Nobody" : owner) << " owns this house.\n It costs " << price << " gold coins."; 
    return doortext.str();
}

Pisane z telefonu.
 
Back
Top