Package com.l2jfrozen.gameserver.network.serverpackets

Examples of com.l2jfrozen.gameserver.network.serverpackets.NpcHtmlMessage


    if(eventPlayer == null)
      return;
   
    try
    {
      NpcHtmlMessage adminReply = new NpcHtmlMessage(5);

      TextBuilder replyMSG = new TextBuilder("<html><head><body><center>");
      replyMSG.append("CTF Flag<br><br>");
      replyMSG.append("<font color=\"00FF00\">" + teamName + "'s Flag</font><br1>");
      if(eventPlayer._teamNameCTF!=null && eventPlayer._teamNameCTF.equals(teamName))
        replyMSG.append("<font color=\"LEVEL\">This is your Flag</font><br1>");
      else
        replyMSG.append("<font color=\"LEVEL\">Enemy Flag!</font><br1>");
      if(_started)
      {
        processInFlagRange(eventPlayer);
      }
      else
        replyMSG.append("CTF match is not in progress yet.<br>Wait for a GM to start the event<br>");
      replyMSG.append("</center></body></html>");
      adminReply.setHtml(replyMSG.toString());
      eventPlayer.sendPacket(adminReply);
    }
    catch(Exception e) {
            LOGGER.error("", e);
            LOGGER.info("CTF Engine[showEventHtlm(" + eventPlayer.getName() + ", " + objectId + ")]: exception: " + e.getStackTrace());
View Full Code Here


    if(!(playable instanceof L2PcInstance))
      return;
    int itemId = item.getItemId();
    if(itemId == 7063)
    {
      NpcHtmlMessage html = new NpcHtmlMessage(5);
      TextBuilder map = new TextBuilder("<html><title>Map - Forest of the Dead</title>");
      map.append("<body>");
      map.append("<br>");
      map.append("Map :");
      map.append("<br>");
      map.append("<table>");
      map.append("<tr><td>");
      map.append("<img src=\"icon.Quest_deadperson_forest_t00\" width=255 height=255>");
      map.append("</td></tr>");
      map.append("</table>");
      map.append("</body></html>");
      html.setHtml(map.toString());
      playable.sendPacket(html);
    }
  }
View Full Code Here

        player.sendPacket(su);
        su = null;
      }
     
      // Send a Server->Client NpcHtmlMessage() containing the GM console about this L2NpcInstance
      NpcHtmlMessage html = new NpcHtmlMessage(0);
      TextBuilder html1 = new TextBuilder("<html><body><center><font color=\"LEVEL\">NPC Information</font></center>");
      String className = getClass().getName().substring(43);
      html1.append("<br>");
     
      html1.append("Instance Type: " + className + "<br1>Faction: " + getFactionId() + "<br1>Location ID: " + (getSpawn() != null ? getSpawn().getLocation() : 0) + "<br1>");
     
      if (this instanceof L2ControllableMobInstance)
      {
        html1.append("Mob Group: " + MobGroupTable.getInstance().getGroupForMob((L2ControllableMobInstance) this).getGroupId() + "<br>");
      }
      else
      {
        html1.append("Respawn Time: " + (getSpawn() != null ? getSpawn().getRespawnDelay() / 1000 + "  Seconds<br>" : "?  Seconds<br>"));
      }
     
      html1.append("<table border=\"0\" width=\"100%\">");
      html1.append("<tr><td>Object ID</td><td>" + getObjectId() + "</td><td>NPC ID</td><td>" + getTemplate().npcId + "</td></tr>");
      html1.append("<tr><td>Castle</td><td>" + getCastle().getCastleId() + "</td><td>Coords</td><td>" + getX() + "," + getY() + "," + getZ() + "</td></tr>");
      html1.append("<tr><td>Level</td><td>" + getLevel() + "</td><td>Aggro</td><td>" + (this instanceof L2Attackable ? ((L2Attackable) this).getAggroRange() : 0) + "</td></tr>");
      html1.append("</table><br>");
     
      html1.append("<font color=\"LEVEL\">Combat</font>");
      html1.append("<table border=\"0\" width=\"100%\">");
      html1.append("<tr><td>Current HP</td><td>" + getCurrentHp() + "</td><td>Current MP</td><td>" + getCurrentMp() + "</td></tr>");
      html1.append("<tr><td>Max.HP</td><td>" + (int) (getMaxHp() / getStat().calcStat(Stats.MAX_HP, 1, this, null)) + "*" + getStat().calcStat(Stats.MAX_HP, 1, this, null) + "</td><td>Max.MP</td><td>" + getMaxMp() + "</td></tr>");
      html1.append("<tr><td>P.Atk.</td><td>" + getPAtk(null) + "</td><td>M.Atk.</td><td>" + getMAtk(null, null) + "</td></tr>");
      html1.append("<tr><td>P.Def.</td><td>" + getPDef(null) + "</td><td>M.Def.</td><td>" + getMDef(null, null) + "</td></tr>");
      html1.append("<tr><td>Accuracy</td><td>" + getAccuracy() + "</td><td>Evasion</td><td>" + getEvasionRate(null) + "</td></tr>");
      html1.append("<tr><td>Critical</td><td>" + getCriticalHit(null, null) + "</td><td>Speed</td><td>" + getRunSpeed() + "</td></tr>");
      html1.append("<tr><td>Atk.Speed</td><td>" + getPAtkSpd() + "</td><td>Cast.Speed</td><td>" + getMAtkSpd() + "</td></tr>");
      html1.append("</table><br>");
     
      html1.append("<font color=\"LEVEL\">Basic Stats</font>");
      html1.append("<table border=\"0\" width=\"100%\">");
      html1.append("<tr><td>STR</td><td>" + getSTR() + "</td><td>DEX</td><td>" + getDEX() + "</td><td>CON</td><td>" + getCON() + "</td></tr>");
      html1.append("<tr><td>INT</td><td>" + getINT() + "</td><td>WIT</td><td>" + getWIT() + "</td><td>MEN</td><td>" + getMEN() + "</td></tr>");
      html1.append("</table>");
     
      html1.append("<br><center><table><tr><td><button value=\"Edit NPC\" action=\"bypass -h admin_edit_npc " + getTemplate().npcId + "\" width=100 height=15 back=\"sek.cbui94\" fore=\"sek.cbui92\"><br1></td>");
      html1.append("<td><button value=\"Kill\" action=\"bypass -h admin_kill\" width=40 height=15 back=\"sek.cbui94\" fore=\"sek.cbui92\"></td><br1></tr>");
      html1.append("<tr><td><button value=\"Show DropList\" action=\"bypass -h admin_show_droplist " + getTemplate().npcId + "\" width=100 height=15 back=\"sek.cbui94\" fore=\"sek.cbui92\"></td></tr>");
      html1.append("<td><button value=\"Delete\" action=\"bypass -h admin_delete\" width=40 height=15 back=\"sek.cbui94\" fore=\"sek.cbui92\"></td></tr>");
      html1.append("<tr><td><button value=\"Show Skillist\" action=\"bypass -h admin_show_skilllist_npc " + getTemplate().npcId + "\" width=100 height=20 back=\"sek.cbui94\" fore=\"sek.cbui92\"></td><td></td></tr>");
      html1.append("</table></center><br>");
      html1.append("</body></html>");
     
      html.setHtml(html1.toString());
      player.sendPacket(html);
      html = null;
      html1 = null;
      className = null;
    }
    else if (Config.ALT_GAME_VIEWNPC)
    {
      // Set the target of the L2PcInstance player
      player.setTarget(this);
     
      // Send a Server->Client packet MyTargetSelected to the L2PcInstance player
      // The player.getLevel() - getLevel() permit to display the correct color in the select window
      MyTargetSelected my = new MyTargetSelected(getObjectId(), player.getLevel() - getLevel());
      player.sendPacket(my);
      my = null;
     
      // Check if the player is attackable (without a forced attack)
      if (isAutoAttackable(player))
      {
        // Send a Server->Client packet StatusUpdate of the L2NpcInstance to the L2PcInstance to update its HP bar
        StatusUpdate su = new StatusUpdate(getObjectId());
        su.addAttribute(StatusUpdate.CUR_HP, (int) getCurrentHp());
        su.addAttribute(StatusUpdate.MAX_HP, getMaxHp());
        player.sendPacket(su);
        su = null;
      }
     
      NpcHtmlMessage html = new NpcHtmlMessage(0);
      TextBuilder html1 = new TextBuilder("<html><body>");
     
      html1.append("<br><center><font color=\"LEVEL\">[Drop Info]</font></center>");
      html1.append("Rates legend: <font color=\"ff0000\">50%+</font> <font color=\"00ff00\">30%+</font> <font color=\"0000ff\">less than 30%</font>");
      html1.append("<table border=0 width=\"100%\">");
     
      for (final L2DropCategory cat : getTemplate().getDropData())
      {
        final FastList<L2DropData> drops = cat.getAllDrops();
        if (drops != null)
          for (final L2DropData drop : drops)
          {
            if (drop == null || ItemTable.getInstance().getTemplate(drop.getItemId()) == null)
            {
              continue;
            }
           
            String name = ItemTable.getInstance().getTemplate(drop.getItemId()).getName();
           
            if (drop.getChance() >= 600000)
            {
              html1.append("<tr><td><font color=\"ff0000\">" + name + "</font></td><td>" + (drop.isQuestDrop() ? "Quest" : cat.isSweep() ? "Sweep" : "Drop") + "</td></tr>");
            }
            else if (drop.getChance() >= 300000)
            {
              html1.append("<tr><td><font color=\"00ff00\">" + name + "</font></td><td>" + (drop.isQuestDrop() ? "Quest" : cat.isSweep() ? "Sweep" : "Drop") + "</td></tr>");
            }
            else
            {
              html1.append("<tr><td><font color=\"0000ff\">" + name + "</font></td><td>" + (drop.isQuestDrop() ? "Quest" : cat.isSweep() ? "Sweep" : "Drop") + "</td></tr>");
            }
          }
      }
     
      html1.append("</table>");
      html1.append("</body></html>");
     
      html.setHtml(html1.toString());
      player.sendPacket(html);
     
      html = null;
      html1 = null;
    }
View Full Code Here

    // {
    if (isBusy() && getBusyMessage().length() > 0)
    {
      player.sendPacket(ActionFailed.STATIC_PACKET);
     
      NpcHtmlMessage html = new NpcHtmlMessage(getObjectId());
      html.setFile("/data/html/npcbusy.htm");
      html.replace("%busymessage%", getBusyMessage());
      html.replace("%npcname%", getName());
      html.replace("%playername%", player.getName());
      player.sendPacket(html);
      html = null;
    }
    else if (command.equalsIgnoreCase("TerritoryStatus"))
    {
      NpcHtmlMessage html = new NpcHtmlMessage(getObjectId());
      {
        if (getCastle().getOwnerId() > 0)
        {
          html.setFile("/data/html/territorystatus.htm");
          L2Clan clan = ClanTable.getInstance().getClan(getCastle().getOwnerId());
          html.replace("%clanname%", clan.getName());
          html.replace("%clanleadername%", clan.getLeaderName());
        }
        else
        {
          html.setFile("/data/html/territorynoclan.htm");
        }
      }
      html.replace("%castlename%", getCastle().getName());
      html.replace("%taxpercent%", "" + getCastle().getTaxPercent());
      html.replace("%objectId%", String.valueOf(getObjectId()));
      {
        if (getCastle().getCastleId() > 6)
        {
          html.replace("%territory%", "The Kingdom of Elmore");
        }
        else
        {
          html.replace("%territory%", "The Kingdom of Aden");
        }
      }
      player.sendPacket(html);
      html = null;
    }
    else if (command.startsWith("Quest"))
    {
      String quest = "";
      try
      {
        quest = command.substring(5).trim();
      }
      catch (IndexOutOfBoundsException ioobe)
      {
        if (Config.ENABLE_ALL_EXCEPTIONS)
          ioobe.printStackTrace();
      }
      if (quest.length() == 0)
      {
        showQuestWindow(player);
      }
      else
      {
        showQuestWindow(player, quest);
      }
    }
    else if (command.startsWith("Chat"))
    {
      int val = 0;
      try
      {
        val = Integer.parseInt(command.substring(5));
      }
      catch (IndexOutOfBoundsException ioobe)
      {
        if (Config.ENABLE_ALL_EXCEPTIONS)
          ioobe.printStackTrace();
      }
      catch (NumberFormatException nfe)
      {
        if (Config.ENABLE_ALL_EXCEPTIONS)
          nfe.printStackTrace();
      }
      showChatWindow(player, val);
    }
    else if (command.startsWith("Link"))
    {
      String path = command.substring(5).trim();
      if (path.indexOf("..") != -1)
        return;
      String filename = "/data/html/" + path;
      NpcHtmlMessage html = new NpcHtmlMessage(getObjectId());
      html.setFile(filename);
      html.replace("%objectId%", String.valueOf(getObjectId()));
      player.sendPacket(html);
      filename = null;
      html = null;
    }
    else if (command.startsWith("NobleTeleport"))
    {
      if (!player.isNoble())
      {
        String filename = "/data/html/teleporter/nobleteleporter-no.htm";
        NpcHtmlMessage html = new NpcHtmlMessage(getObjectId());
        html.setFile(filename);
        html.replace("%objectId%", String.valueOf(getObjectId()));
        html.replace("%npcname%", getName());
        player.sendPacket(html);
        html = null;
        filename = null;
        return;
      }
      int val = 0;
      try
      {
        val = Integer.parseInt(command.substring(5));
      }
      catch (IndexOutOfBoundsException ioobe)
      {
        if (Config.ENABLE_ALL_EXCEPTIONS)
          ioobe.printStackTrace();
      }
      catch (NumberFormatException nfe)
      {
        if (Config.ENABLE_ALL_EXCEPTIONS)
          nfe.printStackTrace();
      }
      showChatWindow(player, val);
    }
    else if (command.startsWith("Loto"))
    {
      int val = 0;
      try
      {
        val = Integer.parseInt(command.substring(5));
      }
      catch (IndexOutOfBoundsException ioobe)
      {
        if (Config.ENABLE_ALL_EXCEPTIONS)
          ioobe.printStackTrace();
      }
      catch (NumberFormatException nfe)
      {
        if (Config.ENABLE_ALL_EXCEPTIONS)
          nfe.printStackTrace();
      }
      if (val == 0)
      {
        // new loto ticket
        for (int i = 0; i < 5; i++)
        {
          player.setLoto(i, 0);
        }
      }
      showLotoWindow(player, val);
    }
    else if (command.startsWith("CPRecovery"))
    {
      makeCPRecovery(player);
    }
    else if (command.startsWith("SupportMagic"))
    {
      makeSupportMagic(player);
    }
    else if (command.startsWith("GiveBlessing"))
    {
      giveBlessingSupport(player);
    }
    else if (command.startsWith("multisell"))
    {
      L2Multisell.getInstance().SeparateAndSend(Integer.parseInt(command.substring(9).trim()), player, false, getCastle().getTaxRate());
    }
    else if (command.startsWith("exc_multisell"))
    {
      L2Multisell.getInstance().SeparateAndSend(Integer.parseInt(command.substring(13).trim()), player, true, getCastle().getTaxRate());
    }
    else if (command.startsWith("Augment"))
    {
      int cmdChoice = Integer.parseInt(command.substring(8, 9).trim());
      switch (cmdChoice)
      {
        case 1:
          player.sendPacket(new SystemMessage(SystemMessageId.SELECT_THE_ITEM_TO_BE_AUGMENTED));
          player.sendPacket(new ExShowVariationMakeWindow());
          break;
        case 2:
          player.sendPacket(new SystemMessage(SystemMessageId.SELECT_THE_ITEM_FROM_WHICH_YOU_WISH_TO_REMOVE_AUGMENTATION));
          player.sendPacket(new ExShowVariationCancelWindow());
          break;
      }
    }
    else if (command.startsWith("npcfind_byid"))
    {
      try
      {
        L2Spawn spawn = SpawnTable.getInstance().getTemplate(Integer.parseInt(command.substring(12).trim()));
       
        if (spawn != null)
        {
          player.sendPacket(new RadarControl(0, 1, spawn.getLocx(), spawn.getLocy(), spawn.getLocz()));
          spawn = null;
        }
      }
      catch (NumberFormatException nfe)
      {
        if (Config.ENABLE_ALL_EXCEPTIONS)
          nfe.printStackTrace();
       
        player.sendMessage("Wrong command parameters");
      }
    }
    else if (command.startsWith("newbie_give_coupon"))
    {
      try
      {
        NpcHtmlMessage html = new NpcHtmlMessage(getObjectId());
        if (player.getLevel() > 25 || player.getLevel() < 6 || !player.isNewbie())
        {
          html.setFile("data/html/adventurers_guide/31760-3.htm");
          player.sendPacket(html);
        }
        else if (player.getCoupon(0))
        {
          html.setFile("data/html/adventurers_guide/31760-1.htm");
          player.sendPacket(html);
        }
        else
        {
          player.getInventory().addItem("Weapon Coupon", 7832, 1, player, this);
          player.addCoupon(1);
          html.setFile("data/html/adventurers_guide/31760-2.htm");
          player.sendPacket(html);
        }
      }
      catch (NumberFormatException nfe)
      {
        if (Config.ENABLE_ALL_EXCEPTIONS)
          nfe.printStackTrace();
       
        player.sendMessage("Wrong command parameters");
      }
    }
    else if (command.startsWith("newbie_give_weapon"))
    {
      try
      {
        NpcHtmlMessage html = new NpcHtmlMessage(getObjectId());
        if (player.getLevel() > 25 || player.getLevel() < 6 || !player.isNewbie())
        {
          html.setFile("data/html/adventurers_guide/31760-3.htm");
          player.sendPacket(html);
        }
        else
        {
          L2Multisell.getInstance().SeparateAndSend(10010, player, false, getCastle().getTaxRate());
        }
      }
      catch (NumberFormatException nfe)
      {
        if (Config.ENABLE_ALL_EXCEPTIONS)
          nfe.printStackTrace();
       
        player.sendMessage("Wrong command parameters");
      }
    }
    else if (command.startsWith("newbie_return_weapon"))
    {
      try
      {
        NpcHtmlMessage html = new NpcHtmlMessage(getObjectId());
        if (player.getLevel() > 25 || player.getLevel() < 6 || !player.isNewbie())
        {
          html.setFile("data/html/adventurers_guide/31760-3.htm");
          player.sendPacket(html);
        }
        else
        {
          L2Multisell.getInstance().SeparateAndSend(10011, player, false, getCastle().getTaxRate());
        }
      }
      catch (NumberFormatException nfe)
      {
        if (Config.ENABLE_ALL_EXCEPTIONS)
          nfe.printStackTrace();
       
        player.sendMessage("Wrong command parameters");
      }
    }
    else if (command.startsWith("traveller_give_coupon"))
    {
      try
      {
        NpcHtmlMessage html = new NpcHtmlMessage(getObjectId());
        if (player.getLevel() > 25 || player.getClassId().level() != 1 || !player.isNewbie())
        {
          html.setFile("data/html/adventurers_guide/31760-6.htm");
          player.sendPacket(html);
        }
        else if (player.getCoupon(1))
        {
          html.setFile("data/html/adventurers_guide/31760-4.htm");
          player.sendPacket(html);
        }
        else
        {
          player.getInventory().addItem("Weapon Coupon", 7833, 1, player, this);
          player.addCoupon(2);
          html.setFile("data/html/adventurers_guide/31760-5.htm");
          player.sendPacket(html);
        }
      }
      catch (NumberFormatException nfe)
      {
        if (Config.ENABLE_ALL_EXCEPTIONS)
          nfe.printStackTrace();
       
        player.sendMessage("Wrong command parameters");
      }
    }
    else if (command.startsWith("traveller_give_weapon"))
    {
      try
      {
        NpcHtmlMessage html = new NpcHtmlMessage(getObjectId());
        if (player.getLevel() > 25 || player.getClassId().level() != 1 || !player.isNewbie())
        {
          html.setFile("data/html/adventurers_guide/31760-6.htm");
          player.sendPacket(html);
        }
        else
        {
          L2Multisell.getInstance().SeparateAndSend(10012, player, false, getCastle().getTaxRate());
        }
      }
      catch (NumberFormatException nfe)
      {
        if (Config.ENABLE_ALL_EXCEPTIONS)
          nfe.printStackTrace();
       
        player.sendMessage("Wrong command parameters");
      }
    }
    else if (command.startsWith("traveller_return_weapon"))
    {
      try
      {
        NpcHtmlMessage html = new NpcHtmlMessage(getObjectId());
        if (player.getLevel() > 25 || player.getClassId().level() != 1 || !player.isNewbie())
        {
          html.setFile("data/html/adventurers_guide/31760-6.htm");
          player.sendPacket(html);
        }
        else
        {
          L2Multisell.getInstance().SeparateAndSend(10013, player, false, getCastle().getTaxRate());
View Full Code Here

    {
      activeChar.sendPacket(new SystemMessage(SystemMessageId.INCORRECT_TARGET));
      return;
    }

    NpcHtmlMessage adminReply = new NpcHtmlMessage(5);
    adminReply.setFile("data/html/admin/expsp.htm");
    adminReply.replace("%name%", player.getName());
    adminReply.replace("%level%", String.valueOf(player.getLevel()));
    adminReply.replace("%xp%", String.valueOf(player.getExp()));
    adminReply.replace("%sp%", String.valueOf(player.getSp()));
    adminReply.replace("%class%", player.getTemplate().className);
    activeChar.sendPacket(adminReply);

    adminReply = null;
    player = null;
    target = null;
View Full Code Here

   */
  public void insertObjectIdAndShowChatWindow(L2PcInstance player, String content)
  {
    // Send a Server->Client packet NpcHtmlMessage to the L2PcInstance in order to display the message of the L2NpcInstance
    content = content.replaceAll("%objectId%", String.valueOf(getObjectId()));
    NpcHtmlMessage npcReply = new NpcHtmlMessage(getObjectId());
    npcReply.setHtml(content);
    player.sendPacket(npcReply);
    npcReply = null;
  }
View Full Code Here

  public void showLotoWindow(L2PcInstance player, int val)
  {
    int npcId = getTemplate().npcId;
    String filename;
    SystemMessage sm;
    NpcHtmlMessage html = new NpcHtmlMessage(getObjectId());
   
    if (val == 0) // 0 - first buy lottery ticket window
    {
      filename = getHtmlPath(npcId, 1);
      html.setFile(filename);
    }
    else if (val >= 1 && val <= 21) // 1-20 - buttons, 21 - second buy lottery ticket window
    {
      if (!Lottery.getInstance().isStarted())
      {
        // tickets can't be sold
        player.sendPacket(new SystemMessage(SystemMessageId.NO_LOTTERY_TICKETS_CURRENT_SOLD));
        return;
      }
      if (!Lottery.getInstance().isSellableTickets())
      {
        // tickets can't be sold
        player.sendPacket(new SystemMessage(SystemMessageId.NO_LOTTERY_TICKETS_AVAILABLE));
        return;
      }
     
      filename = getHtmlPath(npcId, 5);
      html.setFile(filename);
     
      int count = 0;
      int found = 0;
      // counting buttons and unsetting button if found
      for (int i = 0; i < 5; i++)
      {
        if (player.getLoto(i) == val)
        {
          // unsetting button
          player.setLoto(i, 0);
          found = 1;
        }
        else if (player.getLoto(i) > 0)
        {
          count++;
        }
      }
     
      // if not rearched limit 5 and not unseted value
      if (count < 5 && found == 0 && val <= 20)
      {
        for (int i = 0; i < 5; i++)
          if (player.getLoto(i) == 0)
          {
            player.setLoto(i, val);
            break;
          }
      }
     
      // setting pusshed buttons
      count = 0;
      for (int i = 0; i < 5; i++)
        if (player.getLoto(i) > 0)
        {
          count++;
          String button = String.valueOf(player.getLoto(i));
          if (player.getLoto(i) < 10)
          {
            button = "0" + button;
          }
          String search = "fore=\"L2UI.lottoNum" + button + "\" back=\"L2UI.lottoNum" + button + "a_check\"";
          String replace = "fore=\"L2UI.lottoNum" + button + "a_check\" back=\"L2UI.lottoNum" + button + "\"";
          html.replace(search, replace);
        }
     
      if (count == 5)
      {
        String search = "0\">Return";
        String replace = "22\">The winner selected the numbers above.";
        html.replace(search, replace);
      }
    }
    else if (val == 22) // 22 - selected ticket with 5 numbers
    {
      if (!Lottery.getInstance().isStarted())
      {
        // tickets can't be sold
        player.sendPacket(new SystemMessage(SystemMessageId.NO_LOTTERY_TICKETS_CURRENT_SOLD));
        return;
      }
      if (!Lottery.getInstance().isSellableTickets())
      {
        // tickets can't be sold
        player.sendPacket(new SystemMessage(SystemMessageId.NO_LOTTERY_TICKETS_AVAILABLE));
        return;
      }
     
      int price = Config.ALT_LOTTERY_TICKET_PRICE;
      int lotonumber = Lottery.getInstance().getId();
      int enchant = 0;
      int type2 = 0;
     
      for (int i = 0; i < 5; i++)
      {
        if (player.getLoto(i) == 0)
          return;
       
        if (player.getLoto(i) < 17)
        {
          enchant += Math.pow(2, player.getLoto(i) - 1);
        }
        else
        {
          type2 += Math.pow(2, player.getLoto(i) - 17);
        }
      }
      if (player.getAdena() < price)
      {
        sm = new SystemMessage(SystemMessageId.YOU_NOT_ENOUGH_ADENA);
        player.sendPacket(sm);
        return;
      }
      if (!player.reduceAdena("Loto", price, this, true))
        return;
      Lottery.getInstance().increasePrize(price);
     
      sm = new SystemMessage(SystemMessageId.ACQUIRED);
      sm.addNumber(lotonumber);
      sm.addItemName(4442);
      player.sendPacket(sm);
      sm = null;
     
      L2ItemInstance item = new L2ItemInstance(IdFactory.getInstance().getNextId(), 4442);
      item.setCount(1);
      item.setCustomType1(lotonumber);
      item.setEnchantLevel(enchant);
      item.setCustomType2(type2);
      player.getInventory().addItem("Loto", item, player, this);
      item = null;
     
      InventoryUpdate iu = new InventoryUpdate();
      iu.addItem(item);
      L2ItemInstance adenaupdate = player.getInventory().getItemByItemId(57);
      iu.addModifiedItem(adenaupdate);
      player.sendPacket(iu);
      iu = null;
     
      filename = getHtmlPath(npcId, 3);
      html.setFile(filename);
    }
    else if (val == 23) // 23 - current lottery jackpot
    {
      filename = getHtmlPath(npcId, 3);
      html.setFile(filename);
    }
    else if (val == 24) // 24 - Previous winning numbers/Prize claim
    {
      filename = getHtmlPath(npcId, 4);
      html.setFile(filename);
     
      int lotonumber = Lottery.getInstance().getId();
      String message = "";
      for (L2ItemInstance item : player.getInventory().getItems())
      {
        if (item == null)
        {
          continue;
        }
        if (item.getItemId() == 4442 && item.getCustomType1() < lotonumber)
        {
          message = message + "<a action=\"bypass -h npc_%objectId%_Loto " + item.getObjectId() + "\">" + item.getCustomType1() + " Event Number ";
          int[] numbers = Lottery.getInstance().decodeNumbers(item.getEnchantLevel(), item.getCustomType2());
          for (int i = 0; i < 5; i++)
          {
            message += numbers[i] + " ";
          }
          int[] check = Lottery.getInstance().checkTicket(item);
          if (check[0] > 0)
          {
            switch (check[0])
            {
              case 1:
                message += "- 1st Prize";
                break;
              case 2:
                message += "- 2nd Prize";
                break;
              case 3:
                message += "- 3th Prize";
                break;
              case 4:
                message += "- 4th Prize";
                break;
            }
            message += " " + check[1] + "a.";
          }
          message += "</a><br>";
        }
      }
      if (message == "")
      {
        message += "There is no winning lottery ticket...<br>";
      }
      html.replace("%result%", message);
      message = null;
    }
    else if (val > 24) // >24 - check lottery ticket by item object id
    {
      int lotonumber = Lottery.getInstance().getId();
      L2ItemInstance item = player.getInventory().getItemByObjectId(val);
      if (item == null || item.getItemId() != 4442 || item.getCustomType1() >= lotonumber)
        return;
      int[] check = Lottery.getInstance().checkTicket(item);
     
      sm = new SystemMessage(SystemMessageId.DISSAPEARED_ITEM);
      sm.addItemName(4442);
      player.sendPacket(sm);
      sm = null;
     
      int adena = check[1];
      if (adena > 0)
      {
        player.addAdena("Loto", adena, this, true);
      }
      player.destroyItem("Loto", item, this, false);
      return;
    }
    html.replace("%objectId%", String.valueOf(getObjectId()));
    html.replace("%race%", "" + Lottery.getInstance().getId());
    html.replace("%adena%", "" + Lottery.getInstance().getPrize());
    html.replace("%ticket_price%", "" + Config.ALT_LOTTERY_TICKET_PRICE);
    html.replace("%prize5%", "" + Config.ALT_LOTTERY_5_NUMBER_RATE * 100);
    html.replace("%prize4%", "" + Config.ALT_LOTTERY_4_NUMBER_RATE * 100);
    html.replace("%prize3%", "" + Config.ALT_LOTTERY_3_NUMBER_RATE * 100);
    html.replace("%prize2%", "" + Config.ALT_LOTTERY_2_AND_1_NUMBER_PRIZE);
    html.replace("%enddate%", "" + DateFormat.getDateInstance().format(Lottery.getInstance().getEndDate()));
    player.sendPacket(html);
   
    html = null;
   
    // Send a Server->Client ActionFailed to the L2PcInstance in order to avoid that the client wait another packet
View Full Code Here

  {
    String html = HtmCache.getInstance().getHtm("data/html/" + type + "/" + getNpcId() + "-pk.htm");
   
    if (html != null)
    {
      NpcHtmlMessage pkDenyMsg = new NpcHtmlMessage(getObjectId());
      pkDenyMsg.setHtml(html);
      player.sendPacket(pkDenyMsg);
      player.sendPacket(ActionFailed.STATIC_PACKET);
      html = null;
      return true;
    }
View Full Code Here

      ((L2CastleTeleporterInstance) this).showChatWindow(player);
      return;
    }
   
    // Send a Server->Client NpcHtmlMessage containing the text of the L2NpcInstance to the L2PcInstance
    NpcHtmlMessage html = new NpcHtmlMessage(getObjectId());
    html.setFile(filename);
    filename = null;
   
    // String word = "npc-"+npcId+(val>0 ? "-"+val : "" )+"-dialog-append";
   
    if (this instanceof L2MerchantInstance)
      if (Config.LIST_PET_RENT_NPC.contains(npcId))
      {
        html.replace("_Quest", "_RentPet\">Rent Pet</a><br><a action=\"bypass -h npc_%objectId%_Quest");
      }
    html.replace("%playername%", player.getName());
    html.replace("%objectId%", String.valueOf(getObjectId()));
    html.replace("%festivalMins%", SevenSignsFestival.getInstance().getTimeToNextFestivalStart());
    player.sendPacket(html);
    html = null;
   
    // Send a Server->Client ActionFailed to the L2PcInstance in order to avoid that the client wait another packet
    player.sendPacket(ActionFailed.STATIC_PACKET);
View Full Code Here

   * @param filename The filename that contains the text to send
   */
  public void showChatWindow(L2PcInstance player, String filename)
  {
    // Send a Server->Client NpcHtmlMessage containing the text of the L2NpcInstance to the L2PcInstance
    NpcHtmlMessage html = new NpcHtmlMessage(getObjectId());
    html.setFile(filename);
    html.replace("%objectId%", String.valueOf(getObjectId()));
    player.sendPacket(html);
    html = null;
   
    // Send a Server->Client ActionFailed to the L2PcInstance in order to avoid that the client wait another packet
    player.sendPacket(ActionFailed.STATIC_PACKET);
View Full Code Here

TOP

Related Classes of com.l2jfrozen.gameserver.network.serverpackets.NpcHtmlMessage

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.