Jump to content
  • 0

Error In Deleveler Npc


Question

Posted

I am trying to adapt this NPC to aCis but I faced a problem. 

 

Here is the Script

package custom.DeLevelManager;
import com.l2jserver.gameserver.cache.HtmCache;
import com.l2jserver.gameserver.datatables.ItemTable;
import com.l2jserver.gameserver.model.L2Skill;
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.network.serverpackets.ExBrExtraUserInfo;
import com.l2jserver.gameserver.network.serverpackets.NpcHtmlMessage;
import com.l2jserver.gameserver.network.serverpackets.UserInfo;

/**
 * @author `Heroin
 * Made For Maxcheaters.com
 */
public class DeLevelManager extends Quest
{
	private static final int npcid = 36650; // npc id
	private static final int MinLevel = 10; // Minimum Level, (e.g if you set 10, players wont be able to be level 9).
	private static final int ItemConsumeId = 57; // Item Consume id
	private int levels ; // Item Consume id
	private static final int ItemConsumeNumEveryLevel = 100; // Item ItemConsumeNumEveryLevel
	private static String htm = "data/scripts/custom/DeLevelManager/1.htm"; //html location
	private static String ItemName = ItemTable.getInstance().createDummyItem(ItemConsumeId).getItemName();
	
	public DeLevelManager(int questId, String name, String descr)
	{
		super(questId, name, descr);
		addFirstTalkId(npcid);
		addTalkId(npcid);
		addStartNpc(npcid);
	}
	
	@Override
	public String onAdvEvent(String event, L2Npc npc, L2PcInstance player)
	{
		if (event.startsWith("dlvl"))
		{
			Dlvl(event, npc, player, event);
		}

		return "";
	}
	
	private void Dlvl(String event, L2Npc npc, L2PcInstance player, String command)
	{
		
		try
		{
			String val = command.substring(5);
			int pointer = Integer.parseInt(val);
			int k = player.getLevel();
			levels = k - pointer;
			if (player.getInventory().getItemByItemId(ItemConsumeId) == null)
			{
				player.sendMessage("You don't have enough items!");
				return;
			}
			if (val == null)
			{
				player.sendMessage("Something went wrong!");
				return;
			}
			if (pointer < 10)
			{
				player.sendMessage("Incorrect Level Number!");
				return;
			}
			if (pointer < MinLevel)
			{
				player.sendMessage("Incorrect Level Number!");
				return;
			}
			if (player.getLevel() <= pointer)
			{
				player.sendMessage("Your level is already lower.");
				return;
			}
			if (player.getInventory().getItemByItemId(ItemConsumeId).getCount() < ItemConsumeNumEveryLevel*levels)
			{
				
				player.sendMessage("You don't have enough items!");
				return;
			}
			if (player.getInventory().getItemByItemId(ItemConsumeId).getCount() >= ItemConsumeNumEveryLevel)
			{
				k = player.getLevel();
				final byte lvl = Byte.parseByte(pointer + "");	
				player.getStat().setLevel(lvl);
				player.sendMessage("Congratulations! You are now "+pointer+" level.");
				for(L2Skill sk : player.getAllSkills())
				{
					player.removeSkill(sk);
				}
				player.broadcastStatusUpdate();
				player.broadcastUserInfo();
				player.sendPacket(new UserInfo(player));
				player.sendPacket(new ExBrExtraUserInfo(player));
				player.giveAvailableAutoGetSkills();
				player.giveAvailableSkills(true, true);
				player.sendSkillList();
				levels = k - pointer;
				player.destroyItemByItemId("DlvlManager", ItemConsumeId, ItemConsumeNumEveryLevel*levels, player, true);
			}
		}
		catch (Exception e)
		{
			player.sendMessage("Something went wrong try again.");
		}
	}
	
	
	
	@Override
	public String onFirstTalk(L2Npc npc, L2PcInstance player)
	{
		final int npcId = npc.getNpcId();
		if (player.getQuestState(getName()) == null)
		{
			newQuestState(player);
		}
		if (npcId == npcid)
		{
			String html = HtmCache.getInstance().getHtm(player.getHtmlPrefix(), htm);
			html = html.replaceAll("%player%", player.getName());
			html = html.replaceAll("%itemname%", ItemName);
			html = html.replaceAll("%price%", ""+ItemConsumeNumEveryLevel+"");
			
			NpcHtmlMessage npcHtml = new NpcHtmlMessage(0);
			npcHtml.setHtml(html);
			player.sendPacket(npcHtml);
		}
		return "";
	}
	
	public static void main(final String[] args)
	{
		new DeLevelManager(-1, DeLevelManager.class.getSimpleName(), "custom");
		System.out.println("De Level Manager by `Heroin has been loaded successfully!");
	}
}

This is the error:

String html = HtmCache.getInstance().getHtm(player.getHtmlPrefix(), htm);

5 answers to this question

Recommended Posts

  • 0
Posted
String html = HtmCache.getInstance().getHtm(player.getHtmlPrefix());
maybe

 

You're wrong.

 

Correct answer:

String html = HtmCache.getInstance().getHtm(htm);

 

  • 0
Posted (edited)

I'm fed up to see those idiots 

if (npcId == npcid)

if you registered only a single NPC it can only affect the one you registered. It would have a use only if you register numerous ids and they got a different behavior.

 

And the return isn't even used... Finally if it's to static the data, better write it directly into the htm to avoid crappy stuff.

	@Override
	public String onFirstTalk(L2Npc npc, L2PcInstance player)
	{
		if (player.getQuestState(getName()) == null)
			newQuestState(player);
		
		String html = HtmCache.getInstance().getHtm(htm);
		html = html.replaceAll("%player%", player.getName());
		html = html.replaceAll("%itemname%", ItemName);
		html = html.replaceAll("%price%", ""+ItemConsumeNumEveryLevel+"");
		
		return html;
	}
Edited by Tryskell
  • 0
Posted

What means this error in GS console 

ScriptManager: Error loading "scripts.xml" file, java.lang.InstantiationExceptio
n: net.sf.l2j.gameserver.scripting.scripts.custom.DeLevelManager
  • 0
Posted

That means exactly what does it means

 

 

Error loading "scripts.xml" file

 

You did something wrong there, simple.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
×
  • Create New...