Pastebin

New pastes are no longer accepted · Stats

Latest Pastes

character.cpp housing

void Character::House()
{
  int  x, y, house;

  for(int i = 0 ; i < static_cast<int>(this->world->house_config["Amount"]) ; i++){
  x = static_cast<int>(this->world->house_config[util::to_string(i+1) + ".x"]);
  y = static_cast<int>(this->world->house_config[util::to_string(i+1) + ".y"]);
  house = static_cast<int>(this->world->house_config[util::to_string(i+1) + ".house"]);

  if (this->house == house)
      {
       this->PetTransfer();
       this->Warp(house, x, y, WARP_ANIMATION_NONE);
       this->PetTransfer();
      }
   }
}

void Character::LeaveHouse()
{
 if (this->house == this->mapid)
      {
       this->PetTransfer();
       this->Warp(this->SpawnMap(), this->SpawnX(), this->SpawnY(), WARP_ANIMATION_NONE);
       this->PetTransfer();
      }
}

void Character::HousePayment()
{
  PacketBuilder builder;
  PacketBuilder reply;

  short id = 1;int timel;
  int times = 60;int id1, house, rent;
  timel = times -= this->house_usage;

  for(int i = 0 ; i < static_cast<int>(this->world->house_config["Amount"]) ; i++){
  id1 = static_cast<int>(this->world->house_config[util::to_string(i+1) + ".id"]);
  house = static_cast<int>(this->world->house_config[util::to_string(i+1) + ".house"]);
  rent = static_cast<int>(this->world->house_config[util::to_string(i+1) + ".rent"]);

  if(this->house == house)
   {
     if(this->house > 0)
       {
        this->house_usage += static_cast<int>(this->world->config["HouseUsage"]);

        if(this->house_usage >= 30 && this->HasItem(id) >= rent)
         {
          this->house_usage = 0;
          if(this->player->character->DelItem(id, rent));
          {
          builder.SetID(PACKET_ITEM, PACKET_KICK);
          builder.AddShort(id);
          builder.AddInt(this->player->character->HasItem(id));
          builder.AddChar(this->player->character->weight);
          builder.AddChar(this->player->character->maxweight);
          this->player->client->SendBuilder(builder);
         }
        }

      else if(this->house_usage >= 30 && this->house_usage <= 60 && this->HasItem(id) <= rent)
          {
           builder.SetID(PACKET_TALK, PACKET_TELL);
           builder.AddBreakString("landlord");
           builder.AddBreakString(this->name + "YOU HAVE" + ".." + util::to_string(timel) + "MINUTES TO COLLECT YOUR RENT MONEY OR YOUR HOUSE WILL BE SEASED");
           this->player->client->SendBuilder(builder);
          }

        else if(this->house_usage >= 30 && this->house_usage <= 60 && this->HasItem(id) >= rent)
          {
           builder.SetID(PACKET_TALK, PACKET_TELL);
           builder.AddBreakString("LANDLORD");
           builder.AddBreakString(this->name + "THANK YOU FOR YOUR PROMPT PAYMENT (:");
           this->player->client->SendBuilder(builder);
          }

       if(this->house_usage > 60 && this->HasItem(id) <= rent)
         {
          if(this->HasItem(id1) >= 1)
          {
           this->player->character->DelItem(id1, 1);
           reply.SetID(PACKET_ITEM, PACKET_KICK);
           reply.AddShort(id1);
           reply.AddInt(this->player->character->HasItem(id1));
           reply.AddChar(this->player->character->weight);
           reply.AddChar(this->player->character->maxweight);
           this->player->client->SendBuilder(reply);
          }
           this->house = 0;
           this->house_usage = 0;
           this->LeaveHouse();
           builder.SetID(PACKET_TALK, PACKET_TELL);
           builder.AddBreakString("LANDLORD");
           builder.AddBreakString(this->name + "YOUR HOUSE HAS BEEN SEASED >,<");
           this->player->client->SendBuilder(builder);
          }
        }
       this->Save();
     }
  }
}