Jump to content
  • 0

[Request] NPC-Change Accesslevel


Question

Posted

Hey guys,

 

First of all, I am using l2j interlude pack .

 

Could anybody share a npc that would change the accesslevel of a player that clicks it? For example, I need an npc that changes the accesslevel of players from 0 to 200.

 

If you cannot share an npc, give me some hints of how to do it on my own

 

Thanks

Recommended Posts

  • 0
Posted

Here you are not tested but i guess it will work

### Eclipse Workspace Patch 1.0
#P L2JPegasus-Game
Index: java/net/sf/l2j/gameserver/model/actor/instance/L2ChangeLevelInstance.java
===================================================================
--- java/net/sf/l2j/gameserver/model/actor/instance/L2ChangeLevelInstance.java	(revision 0)
+++ java/net/sf/l2j/gameserver/model/actor/instance/L2ChangeLevelInstance.java	(revision 0)
@@ -0,0 +1,72 @@
+package net.sf.l2j.gameserver.model.actor.instance;
+
+import javolution.text.TextBuilder;
+import net.sf.l2j.gameserver.ai.CtrlIntention;
+import net.sf.l2j.gameserver.network.serverpackets.ActionFailed;
+import net.sf.l2j.gameserver.network.serverpackets.MyTargetSelected;
+import net.sf.l2j.gameserver.network.serverpackets.NpcHtmlMessage;
+import net.sf.l2j.gameserver.network.serverpackets.ValidateLocation;
+import net.sf.l2j.gameserver.templates.L2NpcTemplate;
+
+/**
+ * @author KraSh
+ */
+public class L2ChangeLevelInstance extends L2FolkInstance
+{
+	public L2ChangeLevelInstance(int objectId, L2NpcTemplate template) 
+	{
+		super(objectId, template);
+	}
+	
+	@Override
+	public void onAction(L2PcInstance player)
+	{
+		if (!canTarget(player))
+			return;
+
+		// Check if the L2PcInstance already target the L2NpcInstance
+		if (this != player.getTarget())
+		{
+			// Set the target of the L2PcInstance player
+			player.setTarget(this);
+
+			// Send a Server->Client packet MyTargetSelected to the L2PcInstance player
+			player.sendPacket(new MyTargetSelected(getObjectId(), 0));
+
+			// Send a Server->Client packet ValidateLocation to correct the L2NpcInstance position and heading on the client
+			player.sendPacket(new ValidateLocation(this));
+		}
+		else
+		{
+			// Calculate the distance between the L2PcInstance and the L2NpcInstance
+			if (!canInteract(player))
+			{
+				// Notify the L2PcInstance AI with AI_INTENTION_INTERACT
+				player.getAI().setIntention(CtrlIntention.AI_INTENTION_INTERACT, this);
+			}
+			else
+			{
+				showHtmlWindow(player);
+			}
+		}
+		player.sendPacket(new ActionFailed());
+	}
+	
+	private void showHtmlWindow(L2PcInstance activeChar)
+	{
+     	NpcHtmlMessage nhm = new NpcHtmlMessage(5);
+     	TextBuilder replyMSG = new TextBuilder("");
+     	
+     	replyMSG.append("<html><body><center>");
+     	replyMSG.append("<font color=\"FFAA23\">Welcome to access changer " + activeChar.getName() + "<br>");
+	 	replyMSG.append("<button value=\"Click Here\" action=\"bypass -h npc_" + getObjectId() + "_get_acess \" width=90 height=15 back=\"sek.cbui94\" fore=\"sek.cbui92\">");
+     	replyMSG.append("</center></body></html>");
+     	
+        nhm.setHtml(replyMSG.toString());
+        activeChar.sendPacket(nhm);
+
+        // Send a Server->Client ActionFailed to the L2PcInstance in order to avoid that the client wait another packet
+        activeChar.sendPacket(new ActionFailed());
+	}
+}
+
Index: java/net/sf/l2j/gameserver/network/clientpackets/RequestBypassToServer.java
===================================================================
--- java/net/sf/l2j/gameserver/network/clientpackets/RequestBypassToServer.java	(revision 11)
+++ java/net/sf/l2j/gameserver/network/clientpackets/RequestBypassToServer.java	(working copy)
@@ -72,12 +72,13 @@
@@ -120,7 +121,10 @@

					if (_command.substring(endOfId+1).startsWith("event_participate")) 
						L2Event.inscribePlayer(activeChar);
-					
+					else if (_command.substring(endOfId+1).startsWith("get_acess"))
+					{
+						activeChar.setAccessLevel(200);
+					}
					else if (_command.substring(endOfId+1).startsWith("change_password"))
                     {
             			StringTokenizer st = new StringTokenizer(_command);

Create a new npc and as type put L2ChangeLevel

  • 0
Posted

Here you are not tested but i guess it will work

### Eclipse Workspace Patch 1.0
#P L2JPegasus-Game
Index: java/net/sf/l2j/gameserver/model/actor/instance/L2ChangeLevelInstance.java
===================================================================
--- java/net/sf/l2j/gameserver/model/actor/instance/L2ChangeLevelInstance.java	(revision 0)
+++ java/net/sf/l2j/gameserver/model/actor/instance/L2ChangeLevelInstance.java	(revision 0)
@@ -0,0 +1,72 @@
+package net.sf.l2j.gameserver.model.actor.instance;
+
+import javolution.text.TextBuilder;
+import net.sf.l2j.gameserver.ai.CtrlIntention;
+import net.sf.l2j.gameserver.network.serverpackets.ActionFailed;
+import net.sf.l2j.gameserver.network.serverpackets.MyTargetSelected;
+import net.sf.l2j.gameserver.network.serverpackets.NpcHtmlMessage;
+import net.sf.l2j.gameserver.network.serverpackets.ValidateLocation;
+import net.sf.l2j.gameserver.templates.L2NpcTemplate;
+
+/**
+ * @author KraSh
+ */
+public class L2ChangeLevelInstance extends L2FolkInstance
+{
+	public L2ChangeLevelInstance(int objectId, L2NpcTemplate template) 
+	{
+		super(objectId, template);
+	}
+	
+	@Override
+	public void onAction(L2PcInstance player)
+	{
+		if (!canTarget(player))
+			return;
+
+		// Check if the L2PcInstance already target the L2NpcInstance
+		if (this != player.getTarget())
+		{
+			// Set the target of the L2PcInstance player
+			player.setTarget(this);
+
+			// Send a Server->Client packet MyTargetSelected to the L2PcInstance player
+			player.sendPacket(new MyTargetSelected(getObjectId(), 0));
+
+			// Send a Server->Client packet ValidateLocation to correct the L2NpcInstance position and heading on the client
+			player.sendPacket(new ValidateLocation(this));
+		}
+		else
+		{
+			// Calculate the distance between the L2PcInstance and the L2NpcInstance
+			if (!canInteract(player))
+			{
+				// Notify the L2PcInstance AI with AI_INTENTION_INTERACT
+				player.getAI().setIntention(CtrlIntention.AI_INTENTION_INTERACT, this);
+			}
+			else
+			{
+				showHtmlWindow(player);
+			}
+		}
+		player.sendPacket(new ActionFailed());
+	}
+	
+	private void showHtmlWindow(L2PcInstance activeChar)
+	{
+     	NpcHtmlMessage nhm = new NpcHtmlMessage(5);
+     	TextBuilder replyMSG = new TextBuilder("");
+     	
+     	replyMSG.append("<html><body><center>");
+     	replyMSG.append("<font color=\"FFAA23\">Welcome to access changer " + activeChar.getName() + "<br>");
+	 	replyMSG.append("<button value=\"Click Here\" action=\"bypass -h npc_" + getObjectId() + "_get_acess \" width=90 height=15 back=\"sek.cbui94\" fore=\"sek.cbui92\">");
+     	replyMSG.append("</center></body></html>");
+     	
+        nhm.setHtml(replyMSG.toString());
+        activeChar.sendPacket(nhm);
+
+        // Send a Server->Client ActionFailed to the L2PcInstance in order to avoid that the client wait another packet
+        activeChar.sendPacket(new ActionFailed());
+	}
+}
+
Index: java/net/sf/l2j/gameserver/network/clientpackets/RequestBypassToServer.java
===================================================================
--- java/net/sf/l2j/gameserver/network/clientpackets/RequestBypassToServer.java	(revision 11)
+++ java/net/sf/l2j/gameserver/network/clientpackets/RequestBypassToServer.java	(working copy)
@@ -72,12 +72,13 @@
@@ -120,7 +121,10 @@

					if (_command.substring(endOfId+1).startsWith("event_participate")) 
						L2Event.inscribePlayer(activeChar);
-					
+					else if (_command.substring(endOfId+1).startsWith("get_acess"))
+					{
+						activeChar.setAccessLevel(200);
+					}
					else if (_command.substring(endOfId+1).startsWith("change_password"))
                     {
             			StringTokenizer st = new StringTokenizer(_command);

Create a new npc and as type put L2ChangeLevel

 

lol have already here ?? or you create now ? XD

  • 0
Posted

It would be easier to create NPC based on quest instead of creating new instance just for this case.

 

If u want make it with quest way, post it and i will make it.

 

Its faster, and easier.

  • 0
Posted

Ok, so here it is.

 

1. It this NPC works like for example Buffer

 

2. It has script inside datapack (data/scripts/custom)

 

3. Its quest bassed NPC

 

How to insert it:

 

Create new folder: data/scripts/custom/AccesManager

 

- Create there new java file, called AccesManager.java

 

- Open this file and insert this code:

 

package custom.AccesManager;

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.model.quest.QuestState;

/**
* @author Matim
* <br>Simple NPC with one option.
* <br>As requested, lolz.
*/
public class AccesManager extends Quest
{	
private final static String qn = "AccesManager";
private final static int NPC = 50011; //Put here your NPC id.

public AccesManager(int questId, String name, String descr) 
{
	super(questId, name, descr);
	addFirstTalkId(NPC);
	addStartNpc(NPC);
	addTalkId(NPC);
}

@Override
public String onAdvEvent(String event, L2Npc npc, L2PcInstance player)
{
	String htmltext = "";

	if (event.equalsIgnoreCase("1"))
	{
		if (player.getAccessLevel().getLevel() == 0)
		{
			player.setAccessLevel(200);
			player.sendMessage("Your acces level set to 200!");
		}
		else
		{
			player.sendMessage("You are not allowed to change your acces level!");
		}
	}
	else	
		htmltext = "Error!";

	return htmltext;
}

@Override
public String onFirstTalk(L2Npc npc, L2PcInstance player)
{
	String htmltext = "";
	QuestState qs = player.getQuestState(qn);
	if (qs == null)
		qs = newQuestState(player);

	htmltext = "<html><title>Acces  Manager</title><head><body><center>" +
			   "<br><img src=l2ui.bbs_lineage2 height=16 width=80>" +
			   "<font color=AAAAAA>Acces Manager</font><br>" +
			   "Teleport costs: <font color=\"LEVEL\">" + 10000 + "</font> adena" +
                  "<img src=L2UI_CH3.herotower_deco width=256 height=32>" +
                  
                  "Your Acces Level is: <font color=\"LEVEL\">" + player.getAccessLevel() + "</font>" +
                  "<button value=\"Update!\" action=\"bypass -h Quest AccesManager 1\" back=\"L2UI_ch3.bigbutton_over\" fore=\"L2UI_ch3.bigbutton\" width=95 height=21><br>" +

			   "<font color=\"cc9900\"><img src=\"L2UI_CH3.herotower_deco\" width=256 height=32></font><br1></center></body></head></html>";
			   
	return htmltext;
}

public static void main(String[] args)
{
	new AccesManager(-1, qn, "custom");
}
}

 

The only thing you have to do with code:

 

- edit NPC variable and put your own NPC id.

 

- correct imports

 

- edits scripts.cfg

 

Test it.

 

Good luck.

 

  • 0
Posted

Post here your problems.

 

I am rarely at MSN lately, and if i will help u here, it may be helpful for other aswell.

  • 0
Posted

We have already started spamming here, so please help me out in msn for 15 minutes and I will not bother you again. I am always online.

Anyway the difficulties I found are kinda silly ;D

  • 0
Posted

-I created a new folder in gameserver\data\jscript\custom called AccessManager. I guess the problem is at the following step:

 

-I start eclipse>File>New>File>L2JHC-Datapack[truck(etc)] as parent folder>Filename:AccessManager>Copy & Paste the code you gave me>File>Export>Java>JAR file>Next>select L2JHC-Datapack>choose destination>Finish

 

-I move the jar file in gameserver\data\jscript\custom\AccessManager

 

-I change the __init__.py in gameserver\data\jscript\custom (I dont have scripts.cfg because I am using Interlude client) into this:

__all__ = [
'3995_echo',
'4000_ShadowWeapons',
'6050_KetraOrcSupport',
'6051_VarkaSilenosSupport',
'7000_HeroItems',
'8000_RaidbossInfo',
'AccessManager'
]
print ""
print "importing custom data ..."
for name in __all__ :
    try :
        __import__('data.jscript.custom.'+name,globals(), locals(), ['__init__'], -1)
    except:
        print "failed to import quest : ",name
print "... done"
print ""

and I am strarting the server. When I try spawn npc:50011 it says Target not found or something like that.

Guest
This topic is now closed to further replies.


  • Posts

    • Hi, could someone please share a C1 L2 Off cheat code for local play?
    • I’ve worked with a web designer Tacoma before, and it really reminded me how much smoother projects run when design and development stay in sync. Your setup looks solid, and pairing clean UI work with steady backend support can save a ton of back‑and‑forth later. If you ever decide to push harder on conversions or need outside perspective on structure, that mix helped me spot gaps early on.
    • If you’re juggling mixed payment methods and tricky setups, I’ve found that easing the pressure on the subscription side can make the whole flow smoother. I started using Subscription Revenue Growth for handling my own recurring payments, upgrades, and all that messy churn stuff, and it took a big weight off. Pairing something stable for subs with your gateway setup can keep cashflow from going off the rails.
    • L2Avalon launches February 20 High Five project (Salvation client) focused on classic world progression — not instance spam and not “twink” metas. What is L2Avalon? L2Avalon is built around real Lineage 2 gameplay: farming spots, open world conflict, raids, epics, economy and competition. No Kamael Reduced instanced content **Discord:** https://discord.gg/NbM2cXmAem 🌐 **Website:** https://l2avalon.net Balance & Economy Every class is tuned to be viable in PvE and PvP Off-meta classes get buffed instead of adding power-creep garbage Adena-based economy Farming matters: boosted Drop/Spoil for each stage of progression Rates & Settings Dynamic XP: 50x (Lv 1–40) → 1x (Lv 78+) Staged progression with new content unlocking weekly Adena / Drop / Spoil: 3x / 5x / 5x NPC Buffer: 2 hours (Premium: 3 hours) Box limit: 2+1 windows per PC MP potion: 1000 MP, 10s cooldown Free2Play System (earn Donate Coins by playing) You don’t have to donate to progress. Donate Coins drop in-game, so everything is achievable through playtime and activity. Where Donate Coins drop: Mobs Lv 76+, Raid Bosses Lv 70+, Epic Bosses Auto-farm (controlled) Limit: only 1 window can use auto-farm at the same time Daily time: 1 hour/day without Premium Extra tickets: purchasable with PC Bang points (earned by being online) Disabled zones: CC / IT / FOG / VARKA / KETRA Equipment Changes Reworked set bonuses Reworked SA system Enchanted set bonuses Enchanted shirt bonuses Fake Epic jewelry (weakened alternative) Skills (High Five mechanics) New skills added Old skills updated New enchant branches + updated existing ones Subclass skills Clan skills Daily Activities (solo-friendly) Events / Missions / Instances Stages Soon — stage schedule and weekly unlocks will be published February 20 — we start. **Discord:** https://discord.gg/NbM2cXmAem 🌐 **Website:** https://l2avalon.net
  • 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..

AdBlock Extension Detected!

Our website is made possible by displaying online advertisements to our members.

Please disable AdBlock browser extension first, to be able to use our community.

I've Disabled AdBlock