Jump to content
  • 0

[HELP] Item opens html


Question

Posted

Hello again MxC thanks for your attention...

 

I want your help once more if someone can make a specifique item that opens an html...

 

More detailed I want a usable once item that can't be used on oly, tvt, dead, karma, flagged, fake death,

to open an html...

 

I have found some posts like this one: http://maxcheaters.com/forum/index.php?topic=47545.0

 

But steal not what i want!!! If someone can improve it work for latest l2jserver rev

 

It would be awsome!!!

 

Thanks in advance for reading it!!!

14 answers to this question

Recommended Posts

  • 0
Posted

Its really easy to do.

 

Simply create new item handler for it.

 

You can even c/p restrictions from other item handler or custom share.

 

And few lines of code to open new htm window  (also may be taken from different shares, if u don't know this code)

  • 0
Posted

Simply to open htm window, use this:

 

String html = null;

html = HtmCache.getInstance().getHtm(null, "data/html/filename" + htm);

 

NpcHtmlMessage msg = new NpcHtmlMessage(getObjectId());

msg.setHtml(html);

msg.replace("%objectId%", String.valueOf(getObjectId()));

player.sendPacket(msg);

  • 0
Posted

Oh right, u expect ready code without any own effort?

 

Wrong section, its not martketplace where you can request ready things.

 

Its request dev help, we can post some advices, some tips etc.

 

I gave you code to open html, told you to create item handler.

 

Nothing more to do, just use your brain and put some own effort to do it, and.. done!

  • 0
Posted

Sorry i didn't request the hole code just a little help

 

This code you gave me goes to HtmCache i think sorry i'm kind of newbie in java yet

 

I already created the item handler but the item still not working...

 

I registered it on masterhandler also...

 

and still nothing what else can i do?

 

Does anybody knows the code for the restriction or a part of it i can continue it from there!!!

 

Hmm, open a html with what options? Just a simple html, no buttons(with bypasses i mean)?

 

Nothing just open the html!!! with the restrictions!!!

  • 0
Posted

Show us your code, we will check it and we will provide support for it.

 

About those check, they are really simple, sample:

 

if (player.getKarma > 0)

{

    player.sendMessage("Players with karma are not allowed to use this command!"

    return false;

}

 

Should be simple for everyone, even beginers.

  • 0
Posted

package handlers.itemhandlers;

import com.l2jserver.gameserver.cache.HtmCache;
import com.l2jserver.gameserver.handler.IItemHandler;
import com.l2jserver.gameserver.model.L2ItemInstance;
import com.l2jserver.gameserver.model.actor.L2Playable;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
import com.l2jserver.gameserver.network.serverpackets.NpcHtmlMessage;



public class item implements IItemHandler
{
private static final int[] ITEM_IDS = { 10639 };

public void useItem(L2Playable playable, L2ItemInstance item,boolean forceUse)
    {
      if (!(playable instanceof L2PcInstance))
         return;
      L2PcInstance activeChar = (L2PcInstance)playable;
       int itemId = item.getItemId();
      
   if (itemId == 10639)
       {
	String htmFile = "data/html/merchant/658.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 the code i used...I dont get any problems on gameserver...

I ju

  • 0
Posted

What do you mean? You don't have to modify anything with item, simply register item handler for item and thats all.

 

Item handlers means only action after double click.

  • 0
Posted

Any error/info logs available at gameserver while loading handlers or trying to double click this item?

 

Make sure item id is correct etc.

 

About name of the class, type name is discouraged. By convention, Java type names usually start with an uppercase letter

  • 0
Posted

Absolutely no errors...Yeah i saw that with the name and fixed it on my code i just forgot to fix it here also...

 

When i just dooble click the item nothing happens and the item id is ok!!!

 

Anyway i will keep trying fixing it if i find the solution will post it here!!!

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...