Code:
/*
* This program 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.
*
* This program 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 custom.LevelNPC;
import net.sf.l2j.gameserver.instancemanager.QuestManager;
import net.sf.l2j.gameserver.model.actor.L2Npc;
import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
import net.sf.l2j.gameserver.model.base.Experience;
import net.sf.l2j.gameserver.model.quest.Quest;
import net.sf.l2j.gameserver.model.quest.QuestState;
import net.sf.l2j.gameserver.network.clientpackets.Say2;
import net.sf.l2j.gameserver.network.serverpackets.CreatureSay;
/**
* @author Based on idea of SeaNet
* @author lord_rex
* @since ToDay
*/
public class LevelNPC extends Quest
{
private final static int NPC = 50023;
public LevelNPC(int questId, String name, String descr)
{
super(questId, name, descr);
addFirstTalkId(NPC);
addStartNpc(NPC);
addTalkId(NPC);
}
public String onAdvEvent(String event, L2Npc npc, L2PcInstance player)
{
String htmltext = "";
htmltext = npc.getNpcId() + ".htm";
QuestState st = player.getQuestState(getName());
if (event.equalsIgnoreCase("level_me"))
{
if (st.getPlayer().getLevel() < 1)
st.getPlayer().sendPacket(new CreatureSay(st.getPlayer().getObjectId(), Say2.TELL, "Level NPC", "wtf?"));
else if (st.getQuestItemsCount(57) < 1)
st.getPlayer().sendPacket(new CreatureSay(st.getPlayer().getObjectId(), Say2.TELL, "Level NPC", "You need 10.000.000 adena to add your level."));
else if (st.getPlayer().getKarma() > 0)
st.getPlayer().sendPacket(new CreatureSay(st.getPlayer().getObjectId(), Say2.TELL, "Level NPC", "You are chaotic, go away please!"));
else if (st.getPlayer().getPvpFlag() != 0)
st.getPlayer().sendPacket(new CreatureSay(st.getPlayer().getObjectId(), Say2.TELL, "Level NPC", "You cannot add your level when you are fighting."));
else if (st.getPlayer().isAttackingNow() == true)
st.getPlayer().sendPacket(new CreatureSay(st.getPlayer().getObjectId(), Say2.TELL, "Level NPC", "Leave me please!!!"));
else
{
st.getPlayer().setTarget(st.getPlayer());
st.takeItems(57, 1);
st.getPlayer().getStat().addExpAndSp((st.getPlayer().getExp() - Experience.LEVEL[st.getPlayer().getStat().getLevel() + 84]),0);
}
}
return htmltext;
}
public String onFirstTalk(L2Npc npc, L2PcInstance player)
{
String htmltext = "";
QuestState st = player.getQuestState(getName());
if (st == null)
{
Quest q = QuestManager.getInstance().getQuest(getName());
st = q.newQuestState(player);
}
htmltext = npc.getNpcId() + ".htm";
return htmltext;
}
public static void main(String[] args)
{
new LevelNPC(-1, "LevelNPC", "custom");
}
}
but not happend.