Page 1 of 1

Where it is wrong?

Posted: Sat Oct 10, 2009 3:19 pm
by Punisher
If you want to receive support we need this info to help you properly.
» Find Revision
L2J Revision Number:
L2JDP Revision Number:
I have this code :

Code: Select all

package handlers.itemhandlers; import net.sf.l2j.gameserver.handler.IItemHandler;import net.sf.l2j.gameserver.cache.HtmCache;import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;import net.sf.l2j.gameserver.network.serverpackets.NpcHtmlMessage;import net.sf.l2j.gameserver.model.L2ItemInstance;import net.sf.l2j.gameserver.model.actor.L2Playable;   public class MagicGemOfLight implements IItemHandler{	private static final int[] ITEM_IDS = {8868}; 	public void useItem(L2Playable playable, L2ItemInstance item)    {	      if (!(playable instanceof L2PcInstance))	         return;	      L2PcInstance activeChar = (L2PcInstance)playable;	       int itemId = item.getItemId(); 	   if (itemId == 8868)       {		String htmFile = "data/html/menu.htm";		String htmContent = HtmCache.getInstance().getHtm(htmFile); 			NpcHtmlMessage infoHtml = new NpcHtmlMessage(1);			infoHtml.setHtml(htmContent);			activeChar.sendPacket(infoHtml);       }    }       public int[] getItemIds()    {    	return ITEM_IDS;    }}   
This is when you click on the item It apears an Html code.... But where it is wrong :S

Re: Where it is wrong?

Posted: Sat Oct 10, 2009 7:18 pm
by XavierElf
And what's wrong? What does not work?

Re: Where it is wrong?

Posted: Sat Oct 10, 2009 9:48 pm
by Punisher
it doesnt open html

Re: Where it is wrong?

Posted: Sat Oct 10, 2009 10:02 pm
by Probe
I really have no idea if this will work...
I think it won't because you need an NPC Object Id to send this packet...

Code: Select all

if (itemId == 8868){	String path = "data/html/menu.htm";	NpcHtmlMessage infoHtml = new NpcHtmlMessage(item.getObjectId(),"");	infoHtml.setFile(path);	activeChar.sendPacket(infoHtml);}

but you could also try this I guess...

Code: Select all

if (itemId == 8868){	String path = "data/html/menu.htm";	String htmContent = HtmCache.getInstance().getHtm(htmFile);	TuturialShowHtml infoHtml = new TutorialShowHtml(htmContent);	activeChar.sendPacket(infoHtml);}