Example #1
0
  private static void rewardTeam(TvTEventTeam team) {
    // Iterate over all participated player instances of the winning team
    for (L2PcInstance playerInstance : team.getParticipatedPlayers().values()) {
      // Check for nullpointer
      if (playerInstance == null) {
        continue;
      }

      SystemMessage systemMessage = null;

      // Iterate over all tvt event rewards
      for (int[] reward : Config.TVT_EVENT_REWARDS) {
        final PcInventory inv = playerInstance.getInventory();

        // Check for stackable item, non stackabe items need to be added one by one
        if (ItemTable.getInstance().getTemplate(reward[0]).isStackable()) {
          inv.addItem("TvT Event", reward[0], reward[1], playerInstance, playerInstance);

          if (reward[1] > 1) {
            systemMessage = SystemMessage.getSystemMessage(SystemMessageId.YOU_HAVE_EARNED_S2_S1_S);
            systemMessage.addItemName(reward[0]);
            systemMessage.addLong(reward[1]);
          } else {
            systemMessage = SystemMessage.getSystemMessage(SystemMessageId.YOU_HAVE_EARNED_S1);
            systemMessage.addItemName(reward[0]);
          }

          playerInstance.sendPacket(systemMessage);
        } else {
          for (int i = 0; i < reward[1]; ++i) {
            inv.addItem("TvT Event", reward[0], 1, playerInstance, playerInstance);
            systemMessage = SystemMessage.getSystemMessage(SystemMessageId.YOU_HAVE_EARNED_S1);
            systemMessage.addItemName(reward[0]);
            playerInstance.sendPacket(systemMessage);
          }
        }
      }

      playerInstance.sendPacket(new ExUserInfoInvenWeight(playerInstance));
      final NpcHtmlMessage npcHtmlMessage = new NpcHtmlMessage();
      npcHtmlMessage.setHtml(
          HtmCache.getInstance().getHtm(playerInstance.getHtmlPrefix(), htmlPath + "Reward.html"));
      playerInstance.sendPacket(npcHtmlMessage);
    }
  }
 @RegisterEvent(EventType.ON_PLAYER_LEVEL_CHANGED)
 @RegisterType(ListenerRegisterType.GLOBAL)
 public void OnPlayerLevelChanged(OnPlayerLevelChanged event) {
   final L2PcInstance player = event.getActiveChar();
   if ((player.getLevel() >= MIN_LEVEL)
       && (player.getLevel() <= MAX_LEVEL)
       && (player.getRace() != Race.ERTHEIA)) {
     final QuestState qs = getQuestState(player, false);
     if (qs == null) {
       final NpcHtmlMessage html = new NpcHtmlMessage(0, 0);
       html.setHtml(
           HtmCache.getInstance()
               .getHtm(
                   player.getHtmlPrefix(),
                   "scripts/quests/Q10404_KekropusLetter_AHiddenMeaning/Announce.html"));
       player.sendPacket(html);
     }
   }
 }
Example #3
0
  @Override
  public boolean useBypass(String command, L2PcInstance activeChar, L2Character target) {
    if (!(target instanceof L2MerchantInstance)) {
      return false;
    }

    if (!Config.ALLOW_RENTPET) {
      return false;
    }

    if (!Config.LIST_PET_RENT_NPC.contains(target.getId())) {
      return false;
    }

    try {
      final StringTokenizer st = new StringTokenizer(command, " ");
      st.nextToken();

      if (st.countTokens() < 1) {
        final NpcHtmlMessage msg = new NpcHtmlMessage(((L2Npc) target).getObjectId());
        msg.setHtml(
            "<html><body>Pet Manager:<br>"
                + "You can rent a wyvern or strider for adena.<br>My prices:<br1>"
                + "<table border=0><tr><td>Ride</td></tr>"
                + "<tr><td>Wyvern</td><td>Strider</td></tr>"
                + "<tr><td><a action=\"bypass -h npc_%objectId%_RentPet 1\">30 sec/1800 adena</a></td><td><a action=\"bypass -h npc_%objectId%_RentPet 11\">30 sec/900 adena</a></td></tr>"
                + "<tr><td><a action=\"bypass -h npc_%objectId%_RentPet 2\">1 min/7200 adena</a></td><td><a action=\"bypass -h npc_%objectId%_RentPet 12\">1 min/3600 adena</a></td></tr>"
                + "<tr><td><a action=\"bypass -h npc_%objectId%_RentPet 3\">10 min/720000 adena</a></td><td><a action=\"bypass -h npc_%objectId%_RentPet 13\">10 min/360000 adena</a></td></tr>"
                + "<tr><td><a action=\"bypass -h npc_%objectId%_RentPet 4\">30 min/6480000 adena</a></td><td><a action=\"bypass -h npc_%objectId%_RentPet 14\">30 min/3240000 adena</a></td></tr>"
                + "</table>"
                + "</body></html>");
        msg.replace("%objectId%", String.valueOf(((L2Npc) target).getObjectId()));
        activeChar.sendPacket(msg);
      } else {
        tryRentPet(activeChar, Integer.parseInt(st.nextToken()));
      }

      return true;
    } catch (Exception e) {
      _log.info("Exception in " + getClass().getSimpleName());
    }
    return false;
  }