Jump to content
  • 0

[Request] NPC-Change Accesslevel


Mysterio98

Question

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

Link to comment
Share on other sites

Recommended Posts

  • 0

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

Link to comment
Share on other sites

  • 0

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

Link to comment
Share on other sites

  • 0

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.

Link to comment
Share on other sites

  • 0

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.

 

Link to comment
Share on other sites

  • 0

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

Link to comment
Share on other sites

  • 0

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

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.


  • Posts

    • Well, sorry not sorry for resurrecting old topic, but I believe it's ultimately stupid to implement license checks like Vilmis did 🙂   private static String url = "jdbc:mysql://185.80.128.233/" + getData("Zm9ydW1fZGI="); private static String username = getData("bXJjb3B5cmlnaHQ="); private static String password = getData("Y29weXJpZ2h0XzEyMw=="); con = GlobalDB.getInstance().getConnection(); PreparedStatement statement; statement = con.prepareStatement("SELECT field_6 from core_pfields_content WHERE member_id = ?"); statement.setInt(1, Config.FORUM_USER_ID); ResultSet rset = statement.executeQuery();   This awesome way of coding things leaves us with base64-encoded credentials and DB exposed and accessible globally 😉 Btw he checks his licensing data from some plugin generated table his forum uses. Vilmis took action and ensured that mrcopyright user would have only needed accesses and rights for this operation. But he forgot to ensure that his INFORMATION_SCHEMA database would not be exposed and readable... That leads us to fully readable server variables like version used (10.1.26-MariaDB-0+deb9u1 - pretty ancient DB and OS, I'd assume). From here you can go south and do some kinky stuff, if you want and have knowledge for that. But who cares, right?   Ooh, table core_pfields_content field_6 is IP address which is checked by FORUM_USER_ID. Yep, you can query all IP addresses there (124 of them right now) and also do whatever you want with them! 🙂  The most fun part? Files source has been shared what, more than 2 years ago?  Vilmis still uses very same credentials and never changed it after sources exposure - who cares. Although, "sources" may be way too strong word here. If anyone still use paid Orion versions, I'd suggest packing your shit and leaving immediately, or at least fix this incompetent fool caused problems. It's obvious Vilmis don't care or maybe doesn't even know from the first place how to solve this problem (hint hint - tiny PHP Rest API microservice which would do absolutely the same but without exposing sensitive data?). By doing that, he exposes his infrastructure and YOUR data, and he does that for more than 2 years now 🙂 Developer of century!    
    • rename the l2.bin into l2.exe
    • L2LIVE.PRO- Dynamic Mid-rates Essence Seven Signs GRAND OPENING - July 5, 20:00 GMT+3 (EEST) TEST SERVER IS OPEN - COME AND CHECK IT OUT TODAY! Join our community and be part of it at: https://www.l2live.pro https://discord.gg/k3NMgR4Dmu   Server description * EXP/SP: Dynamic (x1- x100 based on your level, *before* Sayha and EXP buffs * Adena: x50 / Item Drop: x10 / Fishing EXP increased / Attribute EXP increased * Simplified gameplay to stay in the loop while not spending hours and hours farming * Starter Pack containing very useful items for beginners * MP replenishing potions with auto-consumption * No overpowered donations L2LIVE shop * All spellbook coupons, pet spellbook coupons and master books are sold via Game Assistant * Additionally you can buy SP pouches, enchanted talismans, pet training guides and various other consumables for Adena and L-Coin * More items such as cloaks, more talismans, agathions, belts, pendants, enchantment scrolls of various grades, evolution stones, etc will be added! Shop server as a shortcut, and all retail-like ways of earning items are still here! L-Coins * Drops with small change and in random amounts from Lv60+ monsters  * All raidbosses drop random amount of L-Coin Pouches generating up to 420 Lcoin per unit. **Grand Olympiad and Events** * Grand Olympiad is held week day * Format is 1v1, unlimited weekly fights  * Heroes are declared weekly at Sunday * There are three automated events - TvT, CTF and Deathmatch, running at evenings * Orc Fortress, Battle with Balok, Keber Hunter, Archievements Box, Daily Gift Calendar provisional events are active too Custom user commands * .offlineplay command, your character will keep playing till death or server restart * .offlineshop command, keeps your shop sitting until all items are purchased * .apon / .apoff - enable/disable HP/MP autoconsume And lots of other small improvements are waiting for you!   Join our community and be part of it at: https://www.l2live.pro https://discord.gg/k3NMgR4Dmu
  • Topics

×
×
  • Create New...