Witam,
jak w kodzie poniżej można zrobić, aby po kliknięciu na drzwi, widoczna będzie cena domków?
Pozdrawiam!
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;
}
}
}
}
}
}