Jump to content

Recommended Posts

Posted

Hello Maxcheaters ;),

 

Today I've finally achieved what I couldn't do before (I didn't have very good knowledge on how to compile e.t.c)...I've made my Npc's dialogue say my character's name and I thought I'd share :D!

 

Here you go:

 

Description:


I really wanted my server NPC to come 'closer' to the players so , I wanted to make them say the player name on their dialogue, here's a pic of what we're gonna do:

npcsaycharname.jpg

 

Let's start:


Copy this code:

 

if (npcId == yournpcid)
html.setFile("data/html/(path)/(filename).htm");
html.replace("%objectId%", String.valueOf(getObjectId()));
player.sendPacket(html);

 

Then, open up Eclipse and go to : L2_Gameserver/java/net/sf/l2j/gameserver/model/actor/L2Npc.java

open it, press Ctrl+F and find this : // Send a Server->Client NpcHtmlMessage containing the text of the L2NpcInstance to the L2PcInstance

 

Make sure that what you've found looks like this:

 

// Send a Server->Client NpcHtmlMessage containing the text of the L2NpcInstance to the L2PcInstance 
NpcHtmlMessage html = new NpcHtmlMessage(getObjectId());
html.setFile(filename);

 

Next, copy the code and paste it under the one you've found so it'll look like this:

 

// Send a Server->Client NpcHtmlMessage containing the text of the L2NpcInstance to the L2PcInstance 
NpcHtmlMessage html = new NpcHtmlMessage(getObjectId());
html.setFile(filename);
if (npcId == yournpcid)
html.setFile("data/html/(path)/(filename).htm");
html.replace("%playername%", player.getName());
player.sendPacket(html);

 

Now, you must change the following:

 

  • yournpcid
  • (path)/(filename)

 

 

Here's what I've changed and what you should change:

 

// Send a Server->Client NpcHtmlMessage containing the text of the L2NpcInstance to the L2PcInstance

NpcHtmlMessage html = new NpcHtmlMessage(getObjectId());

html.setFile(filename);

if (npcId == 10)

html.setFile("data/html/default/10.htm");

html.replace("%playername%", player.getName());

player.sendPacket(html);

 

If your NPC's ID is e.x: 77710 then it should be "if (npcId == 77710)" and "html.setFile("data/html/default/77710.htm");"

 

'default' is the folder that my html file is located, if your npc is a shop then you should replace "/(path)/" with "/merchant/"

 

The last step is to write in your NPC's html "%playername%" (without brackets).

 

Also , if you want to have it in many .htm files then you simply paste the code again and change the NPC ID and the path. ;)

 

I hope it helps!

 

 

 

Credits:


  • pokiokio - Idea
  • Ashitaka - Code
  • Intrepid - Final touch to the code
     
    Thank you Ashitaka and Intrepid ! I couldn't have made it without you :)

P.S.: You might think the code is no big deal, but for me , a person new to l2j it's quite an achievement!

Posted

Yeap simple getName method, but nice share for newbies. And its Java modification, so i think it should be posted in right section.

Posted

waw nice work pokiokio ;)

only idea is yours? :P

 

I'm afraid yes :P

I had the idea when I didn't know much from coding and today I thought "Why don't I give it a try?", I first used the code without "if (npcId == "npcid")" and every NPC had the same dialogue that I defined in the code. Then I asked Intrepid how to fix it and he told me to use the ""if (npcId == "npcid")" and...I've fixed it :)

Posted

Yeap simple getName method, but nice share for newbies. And its Java modification, so i think it should be posted in right section.

 

*Bumer* Yes, sorry I was a lil' bit in a hurry because I wanted to share :P

Posted

I'm afraid yes :P

I had the idea when I didn't know much from coding and today I thought "Why don't I give it a try?", I first used the code without "if (npcId == "npcid")" and every NPC had the same dialogue that I defined in the code. Then I asked Intrepid how to fix it and he told me to use the ""if (npcId == "npcid")" and...I've fixed it :)

tcp

nice work pantos ;)

Kane kana allo new Code.(kalo kai monos s kai 8a pareis +1 karma )

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now



  • Posts

    • You charge 10,000 - 15,000 USD for Java files and your site shows 370 projects and 786 customers. you're not just a millionaire, you're a multimillionaire bro 😂 and enjoy it while it lasts. Ai is coming in hot and your 18 developers better start updating their CVs. soon everyone will build whatever they need for free. The 15k Java files era is over 😄  
    • Honestly, I don’t care about your files at all. I’m just watching what people are sharing, and what’s interesting is that whenever someone shares your files, or anyone else’s files for that matter, sources included, they’re always old files from like 10 years ago :d.  You act way too cocky.. go see what people are writing about you on MMO Dev, then come talk to me.  
    • Hello everyone, I'm here to ask for help with information about contacting StrixGuard support.   I subscribed to their platform and license a while ago, I haven't had any problems with it and I even managed to block Adrenaline Premium.   I hired them mainly to have some protection and be able to use the HWID on my server. It turned out to work much better than some people had said and than I expected.   Therefore, I purchased another license from Strix for another project, but the problem we encountered was the time difference and language barrier, which complicated things for us in getting it to work on my new project.🤣🤣🤣   But currently, he hasn't responded or connected to Telegram for weeks, which is where I managed to finalize everything.   I understand that due to the situation in Russia regarding communications and networks, it would currently be even more impossible to contact any support.   But if anyone here still has contact information for StrixGuard support, I'd appreciate it if you could share it with me. It doesn't matter if it's a Russian number or a Russian app; I can still use them and make contact. But I need more than just the Telegram contact I have.   So I would greatly appreciate any information... and please refrain from suggesting other anti-cheat programs or that I should switch. All I'm looking for is contact with StrixGuard support, nothing more.   Thank you all very much.
    • If you are interested in purchasing, I will send you the tests DLL files so you can verify their authenticity.
    • Any servers was using your files and where is your test server link ?
  • Topics

×
×
  • Create New...

Important Information

This community uses essential cookies to function properly. Non-essential cookies and third-party services are used only with your consent. Read our Privacy Policy and We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue..