Autor Tema: error en augment shop  (Leído 9 veces)

Febrero 14, 2019, 04:06:33 am

Desconectado onepiecex1994

  • Usuario
  • *
  • Mensajes: 2
  • Karma: 0
hola actualmente trabajo con l2jserver su versión freya quisiera una ayuda con un codigo ya que tengo 2 errores.

/*
 * Copyright (C) 2004-2019 L2J Server
 *
 * This file is part of L2J Server.
 *
 * L2J Server is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * L2J Server is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 * General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program. If not, see <http://www.gnu.org/licenses/>.
 */
package com.l2jserver.scripts.custom.AugmentShop;

import com.l2jserver.gameserver.model.actor.L2Npc;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
import com.l2jserver.gameserver.model.quest.Quest;
import com.l2jserver.gameserver.model.quest.QuestState;
import com.l2jserver.gameserver.model.itemcontainer.Inventory;
import java.sql.Connection;
import java.sql.PreparedStatement;
import com.l2jserver.L2DatabaseFactory;
import java.util.logging.Level;
import com.l2jserver.gameserver.model.L2ItemInstance;

/**
 *
 * @author Rizel
 *
 */
public class AugmentShop extends Quest
{
   private final static int ITEM_ID = 57;
   private final static int ITEM_COUNT = 1000000;
   private final static String qn = "AugmentShop";
   private final static int NPC = 93000;
   
   public AugmentShop(int questId, String name, String descr)
   {
      super(questId, name, descr);
      FirstTalkNpcs(NPC);
      TalkNpcs(NPC);
      StartNpcs(NPC);
   }
   
   @Override
   public String onAdvEvent(String event, L2Npc npc, L2PcInstance player)
   {
      String htmltext = "";
      
      if (event.equalsIgnoreCase("active"))
      {
         htmltext = "active.htm";
      }
      
      else if (event.equalsIgnoreCase("passive"))
      {
         htmltext = "passive.htm";
      }
      
      else if (event.equalsIgnoreCase("chance"))
      {
         htmltext = "chance.htm";
      }
      
      else
      {
         
         updateAugment(player, Integer.parseInt(event.substring(0,5)), Integer.parseInt(event.substring(6,10)), Integer.parseInt(event.substring(11,13)));
      }

      
      return htmltext;
   }

   @Override
   public String onFirstTalk(L2Npc npc, L2PcInstance player)
   {
      String htmltext = "";
      QuestState qs = player.getQuestState(qn);
      if (qs == null)
         qs = newQuestState(player);
      htmltext = "main.htm";
      return htmltext;
   }
   
   public static void main(String[] args)
   {
      new AugmentShop(-1, qn, "AugmentShop");
   }
   
   
   private static void updateAugment(L2PcInstance player, int attribute, int skill, int level)
   {
      L2ItemInstance item = player.getInventory().getPaperdollItem(Inventory.PAPERDOLL_RHAND);
      if (player.getInventory().getPaperdollItem(Inventory.PAPERDOLL_RHAND) == null)
         
      {
         player.sendMessage("You have to equip a weapon.");
         return;
      }
         
      if (player.getInventory().getPaperdollItem(Inventory.PAPERDOLL_RHAND).isAugmented())
      {
         player.sendMessage("The weapon is already augmented.");
         return;
      }
      
      if (player.getInventory().getInventoryItemCount(ITEM_ID, -1) < ITEM_COUNT)
      {
         player.sendMessage("You dont have enough item.");
         return;
      }
         
      Connection con = null;
      try
      {
         player.destroyItemByItemId("Consume", ITEM_ID, ITEM_COUNT, player, true);
         con = L2DatabaseFactory.getInstance().getConnection();
         PreparedStatement statement = con.prepareStatement("REPLACE INTO item_attributes VALUES(?,?,?,?,?,?)");
         statement.setInt(1, item.getObjectId());

            statement.setInt(2, attribute*65536+1);
            statement.setInt(3, skill);
            statement.setInt(4, level);
         
         if (item.getElementals() == null)
         {
            statement.setByte(5, (byte) -1);
            statement.setInt(6, -1);
         }
         else
         {
            statement.setByte(5, item.getElementals().getElement());
            statement.setInt(6, item.getElementals().getValue());
         }
         statement.executeUpdate();
         player.sendMessage("Succesfully augmented. You have to relog now.");
         statement.close();
         
      }
      catch (Exception e)
      {
         _log.log(Level.SEVERE, "Could not augment item: "+item.getObjectId()+" ", e);
      }
      finally
      {
         L2DatabaseFactory.close(con);
      }
   }
   
   
}