Jump to content

Recommended Posts

Posted (edited)

Hello all,


Since I love to help people if my knowledge can provide the solution, I'm here to help you with your requests/problems about l2j.
I'm usually on for 3-4 hours per day so don't expect fast respond.

  • I'd love to create your idea and give you the code ready but get real, I wont spend hours for just one thing , so don't request something big
  • Feel free to ask any thing you cant understand, blame is not allowed here :)
  • I have no idea for anything related to client side.
  • Atm I'm working on aCis project (feel free to ask something which is related to another project ).

 

Finally,

I want to do this because it will be useful (for some members) but for me too, I'm learning java and I would like to improve my skills so I found it great idea.

 

If this post is in wrong section please a mod move it to the proper one :) Thank you!

 

Edited by SailFpO
Posted

maybe can you help me , how to disable Quiz event on l2jmythras files its shered here 

[15:23:48]  INFO Dress me system: Load 27 Big Sword(s).
[15:23:48]  INFO Dress me system: Load 4 Rod(s).
[15:23:48]  INFO Dress me system: Load 44 Big Blunt(s).
[15:23:48]  INFO Dress me system: Load 20 Crossbow(s).
[15:23:48]  INFO Dress me system: Load 21 Rapier(s).
[15:23:48]  INFO Dress me system: Load 21 Ancient Sword(s).
[15:23:48]  INFO Dress me system: Load 9 Dual Dagger(s).
Loading Quiz.java
[15:23:51]  INFO Loaded Service: ScripsConfig
[15:23:51]  INFO Loaded Service: SellPcService
[15:23:51]  INFO CommunityBoard: Manage Career service loaded.
[15:23:51]  INFO CommunityBoard: Auction System Service loaded.
[15:23:51]  INFO CommunityBoard: service loaded.
[15:23:51]  INFO CommunityBoard: Bosses loaded.
[15:23:51]  INFO CommunityBoard: Clan Community service loaded.
[15:23:51]  INFO CommunityBoard: Drop Calculator service loaded.

im tring to find where i can turn it off but cant. can you help?

Posted (edited)

Take a look in your gameserver.java if there exists a line 'Quiz.getinstance()' , if you found it just add // or delete it

p.s. it could be with configs for enable/disable

Edited by SailFpO
Posted
3 hours ago, Benskis said:

Hey, maybe You could share Your buffer's code if You have one. I just hate scheme buffers. 

Well I do not have anything because I'm not planning to open a server :P , you can find infinity buffers here in mxc especially without scheme options

Posted
12 minutes ago, Blood Tears ♡ said:

I need simple npc for l2jacis , I want to be something like this:
it will requre item "X" to get item "Y", and the second option is to buy equipment with item "Y"

There is a donate shop shared you can take it and see how things works reading a code it will be helpful

Posted (edited)

Request from: Blood Tears ♡

3 hours ago, Blood Tears ♡ said:

I need simple npc for l2jacis , I want to be something like this:
it will requre item "X" to get item "Y", and the second option is to buy equipment with item "Y"

Let me know if you need configs.

code:

 

Source:

### Eclipse Workspace Patch 1.0
#P aCis_gameserver
Index: java/net/sf/l2j/gameserver/model/actor/instance/Trader.java
===================================================================
--- java/net/sf/l2j/gameserver/model/actor/instance/Trader.java	(nonexistent)
+++ java/net/sf/l2j/gameserver/model/actor/instance/Trader.java	(working copy)
@@ -0,0 +1,72 @@
+package net.sf.l2j.gameserver.model.actor.instance;
+
+import java.util.StringTokenizer;
+
+import net.sf.l2j.gameserver.model.actor.template.NpcTemplate;
+import net.sf.l2j.gameserver.network.SystemMessageId;
+import net.sf.l2j.gameserver.network.serverpackets.SystemMessage;
+
+public class Trader extends Folk
+{
+	private static final int[] REQUIRE_ITEM_FOR_EX =
+	{
+		3031,	//the item that the user must have to exchange it with the REWARD_ITEM
+		10 		//the count
+	};
+	private static final int[] REWARD_ITEM =
+	{
+		1872,	//the item that will get after the exchange
+		1		//the count
+	};
+	
+	private static final int REQUIRE_EQUIP_ITEM_CNT = 1;	//the count of items that the npc will consume to give the equip item, the id is the REWARD_ITEM[0]
+	private static final int EQUIP_ITEM_ID[] =
+	{
+		7575,	//the equipment item
+		1		//the count
+	};
+
+
+	
+	public Trader(int objectId, NpcTemplate template)
+	{
+		super(objectId, template);
+	}
+	
+	@Override
+	public void onBypassFeedback(Player player, String command)
+	{
+		StringTokenizer st = new StringTokenizer(command, " ");
+		String currentCommand = st.nextToken();
+		
+		if (currentCommand.startsWith("exchange"))
+		{
+			if (!player.destroyItemByItemId("ex", REQUIRE_ITEM_FOR_EX[0], REQUIRE_ITEM_FOR_EX[1], null, true))
+				player.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.NOT_ENOUGH_REQUIRED_ITEMS));
+			else
+				player.addItem("rew", REWARD_ITEM[0], REWARD_ITEM[1], null, true);
+		}
+		else if (currentCommand.startsWith("buy"))
+		{
+			if (!player.destroyItemByItemId("ex", REWARD_ITEM[0], REQUIRE_EQUIP_ITEM_CNT, null, true))
+				player.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.NOT_ENOUGH_REQUIRED_ITEMS));
+			else
+				player.addItem("rew", EQUIP_ITEM_ID[0], EQUIP_ITEM_ID[1], null, true);
+		}
+		
+		super.onBypassFeedback(player, command);
+	}
+	
+	@Override
+	public String getHtmlPath(int npcId, int val)
+	{
+		String filename = "";
+		if (val == 0)
+			filename = "" + npcId;
+		else
+			filename = npcId + "-" + val;
+		
+		return "data/html/mods/Trader/" + filename + ".htm";
+	}
+	
+}
\ No newline at end of file


Npc XML:
### Eclipse Workspace Patch 1.0
#P aCis_datapack
Index: data/xml/npcs/50000-50999.xml
===================================================================
--- data/xml/npcs/50000-50999.xml	(revision 4)
+++ data/xml/npcs/50000-50999.xml	(working copy)
@@ -111,4 +111,42 @@
 			<skill id="4416" level="18"/>
 		</skills>
 	</npc>
+	
+		<npc id="50009" idTemplate="30519" name="Trader" title="Crappy Trader">
+		<set name="usingServerSideName" val="true"/>
+		<set name="usingServerSideTitle" val="true"/>
+		<set name="level" val="70"/>
+		<set name="radius" val="7"/>
+		<set name="height" val="18"/>
+		<set name="rHand" val="0"/>
+		<set name="lHand" val="0"/>
+		<set name="type" val="Trader"/>
+		<set name="exp" val="0"/>
+		<set name="sp" val="0"/>
+		<set name="hp" val="2444.46819"/>
+		<set name="mp" val="1345.8"/>
+		<set name="hpRegen" val="7.5"/>
+		<set name="mpRegen" val="2.7"/>
+		<set name="pAtk" val="688.86373"/>
+		<set name="pDef" val="295.91597"/>
+		<set name="mAtk" val="470.40463"/>
+		<set name="mDef" val="216.53847"/>
+		<set name="crit" val="4"/>
+		<set name="atkSpd" val="253"/>
+		<set name="str" val="40"/>
+		<set name="int" val="21"/>
+		<set name="dex" val="30"/>
+		<set name="wit" val="20"/>
+		<set name="con" val="43"/>
+		<set name="men" val="20"/>
+		<set name="corpseTime" val="7"/>
+		<set name="walkSpd" val="50"/>
+		<set name="runSpd" val="120"/>
+		<set name="dropHerbGroup" val="0"/>
+		<ai type="DEFAULT" ssCount="0" ssRate="0" spsCount="0" spsRate="0" aggro="0" canMove="true" seedable="false"/>
+		<skills>
+			<skill id="4045" level="1"/>
+			<skill id="4416" level="18"/>
+		</skills>
+	</npc>
 </list>
\ No newline at end of file


Npc HTML:
### Eclipse Workspace Patch 1.0
#P aCis_datapack
Index: data/html/mods/trader/50009.htm
===================================================================
--- data/html/mods/trader/50009.htm	(nonexistent)
+++ data/html/mods/trader/50009.htm	(working copy)
@@ -0,0 +1,8 @@
+<html><body>
+	<center>
+	Your custom staff here.
+	
+	<button value="exchange" action="bypass npc_%objectId%_exchange" height=15 width=45 back="sek.cbui94" fore="sek.cbui92">
+	<button value="buy" action="bypass npc_%objectId%_buy" height=15 width=45 back="sek.cbui94" fore="sek.cbui92">
+	
+</body></html>
\ No newline at end of file


 

 

You have to create a new folder in data/html/mods with name trader and inside create a new html with the npc id as name. (in my case was 50009), then paste the html code

Edited by SailFpO
Posted
1 hour ago, SailFpO said:

Request from: Blood Tears ♡

Let me know if you need configs.

code:

  Reveal hidden contents


Source:

### Eclipse Workspace Patch 1.0
#P aCis_gameserver
Index: java/net/sf/l2j/gameserver/model/actor/instance/Trader.java
===================================================================
--- java/net/sf/l2j/gameserver/model/actor/instance/Trader.java	(nonexistent)
+++ java/net/sf/l2j/gameserver/model/actor/instance/Trader.java	(working copy)
@@ -0,0 +1,72 @@
+package net.sf.l2j.gameserver.model.actor.instance;
+
+import java.util.StringTokenizer;
+
+import net.sf.l2j.gameserver.model.actor.template.NpcTemplate;
+import net.sf.l2j.gameserver.network.SystemMessageId;
+import net.sf.l2j.gameserver.network.serverpackets.SystemMessage;
+
+public class Trader extends Folk
+{
+	private static final int[] REQUIRE_ITEM_FOR_EX =
+	{
+		3031,	//the item that the user must have to exchange it with the REWARD_ITEM
+		10 		//the count
+	};
+	private static final int[] REWARD_ITEM =
+	{
+		1872,	//the item that will get after the exchange
+		1		//the count
+	};
+	
+	private static final int REQUIRE_EQUIP_ITEM_CNT = 1;	//the count of items that the npc will consume to give the equip item, the id is the REWARD_ITEM[0]
+	private static final int EQUIP_ITEM_ID[] =
+	{
+		7575,	//the equipment item
+		1		//the count
+	};
+
+
+	
+	public Trader(int objectId, NpcTemplate template)
+	{
+		super(objectId, template);
+	}
+	
+	@Override
+	public void onBypassFeedback(Player player, String command)
+	{
+		StringTokenizer st = new StringTokenizer(command, " ");
+		String currentCommand = st.nextToken();
+		
+		if (currentCommand.startsWith("exchange"))
+		{
+			if (!player.destroyItemByItemId("ex", REQUIRE_ITEM_FOR_EX[0], REQUIRE_ITEM_FOR_EX[1], null, true))
+				player.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.NOT_ENOUGH_REQUIRED_ITEMS));
+			else
+				player.addItem("rew", REWARD_ITEM[0], REWARD_ITEM[1], null, true);
+		}
+		else if (currentCommand.startsWith("buy"))
+		{
+			if (!player.destroyItemByItemId("ex", REWARD_ITEM[0], REQUIRE_EQUIP_ITEM_CNT, null, true))
+				player.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.NOT_ENOUGH_REQUIRED_ITEMS));
+			else
+				player.addItem("rew", EQUIP_ITEM_ID[0], EQUIP_ITEM_ID[1], null, true);
+		}
+		
+		super.onBypassFeedback(player, command);
+	}
+	
+	@Override
+	public String getHtmlPath(int npcId, int val)
+	{
+		String filename = "";
+		if (val == 0)
+			filename = "" + npcId;
+		else
+			filename = npcId + "-" + val;
+		
+		return "data/html/mods/Trader/" + filename + ".htm";
+	}
+	
+}
\ No newline at end of file


Npc XML:
### Eclipse Workspace Patch 1.0
#P aCis_datapack
Index: data/xml/npcs/50000-50999.xml
===================================================================
--- data/xml/npcs/50000-50999.xml	(revision 4)
+++ data/xml/npcs/50000-50999.xml	(working copy)
@@ -111,4 +111,42 @@
 			<skill id="4416" level="18"/>
 		</skills>
 	</npc>
+	
+		<npc id="50009" idTemplate="30519" name="Trader" title="Crappy Trader">
+		<set name="usingServerSideName" val="true"/>
+		<set name="usingServerSideTitle" val="true"/>
+		<set name="level" val="70"/>
+		<set name="radius" val="7"/>
+		<set name="height" val="18"/>
+		<set name="rHand" val="0"/>
+		<set name="lHand" val="0"/>
+		<set name="type" val="Trader"/>
+		<set name="exp" val="0"/>
+		<set name="sp" val="0"/>
+		<set name="hp" val="2444.46819"/>
+		<set name="mp" val="1345.8"/>
+		<set name="hpRegen" val="7.5"/>
+		<set name="mpRegen" val="2.7"/>
+		<set name="pAtk" val="688.86373"/>
+		<set name="pDef" val="295.91597"/>
+		<set name="mAtk" val="470.40463"/>
+		<set name="mDef" val="216.53847"/>
+		<set name="crit" val="4"/>
+		<set name="atkSpd" val="253"/>
+		<set name="str" val="40"/>
+		<set name="int" val="21"/>
+		<set name="dex" val="30"/>
+		<set name="wit" val="20"/>
+		<set name="con" val="43"/>
+		<set name="men" val="20"/>
+		<set name="corpseTime" val="7"/>
+		<set name="walkSpd" val="50"/>
+		<set name="runSpd" val="120"/>
+		<set name="dropHerbGroup" val="0"/>
+		<ai type="DEFAULT" ssCount="0" ssRate="0" spsCount="0" spsRate="0" aggro="0" canMove="true" seedable="false"/>
+		<skills>
+			<skill id="4045" level="1"/>
+			<skill id="4416" level="18"/>
+		</skills>
+	</npc>
 </list>
\ No newline at end of file


Npc HTML:
### Eclipse Workspace Patch 1.0
#P aCis_datapack
Index: data/html/mods/trader/50009.htm
===================================================================
--- data/html/mods/trader/50009.htm	(nonexistent)
+++ data/html/mods/trader/50009.htm	(working copy)
@@ -0,0 +1,8 @@
+<html><body>
+	<center>
+	Your custom staff here.
+	
+	<button value="exchange" action="bypass npc_%objectId%_exchange" height=15 width=45 back="sek.cbui94" fore="sek.cbui92">
+	<button value="buy" action="bypass npc_%objectId%_buy" height=15 width=45 back="sek.cbui94" fore="sek.cbui92">
+	
+</body></html>
\ No newline at end of file


 

 

You have to create a new folder in data/html/mods with name trader and inside create a new html with the npc id as name. (in my case was 50009), then paste the html code

Thank you.

Posted

you can make this 

<button value="exchange" action="bypass npc_%objectId%_exchange" height=15 width=45 back="sek.cbui94" fore="sek.cbui92">

as like this

<button value="exchange" action="bypass npc_%objectId%_exchange $count" height=15 width=45 back="sek.cbui94" fore="sek.cbui92">

for player dont need press all time 1 button with <edit var="$count" width=120 height=15> default conut = 1 if box is space

Posted (edited)
6 minutes ago, tazerman2 said:

you can make this 


<button value="exchange" action="bypass npc_%objectId%_exchange" height=15 width=45 back="sek.cbui94" fore="sek.cbui92">

as like this


<button value="exchange" action="bypass npc_%objectId%_exchange $count" height=15 width=45 back="sek.cbui94" fore="sek.cbui92">

for player dont need press all time 1 button with <edit var="$count" width=120 height=15> default conut = 1 if box is space

Well a good code must be secured too, Generally avoid to create codes that uses value from html because this one can be easily bypassed from programs like andrenaline...

Even in buffer case where the bypass is npc_%objectId%_buff 1204 2 can be bypassed to npc_%objectId%_buff 7029 4

and the user will get gm speed lvl 4...

 

p.s Ofc a code like you did with all necessary checks inside can be worked too without any problem but its a huge amount of wasted time :D

 

Ontopic: good job for your time

Edited by melron
Posted (edited)
if (!player.destroyItemByItemId("ex", REQUIRE_ITEM_FOR_EX[0], REQUIRE_ITEM_FOR_EX[1], null, true))
    player.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.NOT_ENOUGH_REQUIRED_ITEMS));
else
    player.addItem("rew", REWARD_ITEM[0], REWARD_ITEM[1], null, true);

You could make it like

if (!player.destroyItemByItemId("ex", REQUIRE_ITEM_FOR_EX[0], REQUIRE_ITEM_FOR_EX[1], null, true))
    return;
	player.addItem("rew", REWARD_ITEM[0], REWARD_ITEM[1], null, true);

If destroyItem.. return false, you get the message about incorect item count. With your message, you get it twice.

Edited by SweeTs
Posted
7 hours ago, SweeTs said:

If destroyItem.. return false, you get the message about incorect item count. With your message, you get it twice.

Well, it's not twice :P if you look carefully

the default one inside of destroyitem.... is

if (sendMessage)
	sendPacket(SystemMessageId.NOT_ENOUGH_ITEMS);

which is the message "Incorrect item count." in the player's chat.

the second one (I added) is

SystemMessageId.NOT_ENOUGH_REQUIRED_ITEMS)

which is the message in dialog "You do not have enough required items." :D

I just like the dialog to appear when the player haven't all the required items. (it's just optional)

  • 3 months later...
Posted (edited)

Hello SailFpO maybe you can help and tell me how can i make empti scroll thets convert my sp to a full sp scroll and then later can sell to some other player? i meen to make player sell they own sp.

Sory for my english.

Edited by kreis
Posted (edited)
1 hour ago, kreis said:

Hello SailFpO maybe you can help and tell me how can i make empti scroll thets convert my sp to a full sp scroll and then later can sell to some other player? i meen to make player sell they own sp.

Sory for my english.

1) You have to create your own item handler

2) You need somewhere to save the value after the server restart. So add one more field in your items table in db to store the sp

3) if you are using acis , at restore() method of class Inventory add one more field in the statement where is loading the informations of items like :

"SELECT object_id, item_id, count, enchant_level, loc, loc_data, custom_type1, custom_type2, mana_left, time, SP FROM items WHERE owner_id=? AND (loc=? OR loc=?) ORDER BY loc_data

4) restoreFromDb() method add one more int 'sp' and handle it. example:

public static ItemInstance restoreFromDb(int ownerId, ResultSet rs)
 	{
 		ItemInstance inst = null;
-		int objectId, item_id, loc_data, enchant_level, custom_type1, custom_type2, manaLeft, count;
+		int objectId, item_id, loc_data, enchant_level, custom_type1, custom_type2, manaLeft, count, sp;
 		long time;
 		ItemLocation loc;
 		try
@@ -878,6 +878,7 @@
 			custom_type2 = rs.getInt("custom_type2");
 			manaLeft = rs.getInt("mana_left");
 			time = rs.getLong("time");
+			sp = rs.getInt("sp");
 		}
 		catch (Exception e)
 		{
@@ -902,6 +903,7 @@
 		inst._locData = loc_data;
 		inst._existsInDb = true;
 		inst._storedInDb = true;
+		inst.setSP(sp, false);
 		
 		// Setup life time for shadow weapons
 		inst._mana = manaLeft;
@@ -1262,4 +1264,41 @@
 		
 		return Integer.compare(item.getObjectId(), getObjectId());
 	}
+	
+	private int SP = 0;
+	
+	public int getSP()
+	{
+		return SP;
+	}
+	
+	public void setSP(int sp, boolean store)
+	{
+		SP = sp;
+		if (store)
+			try (Connection con = L2DatabaseFactory.getInstance().getConnection(); PreparedStatement ps = con.prepareStatement("UPDATE items SET sp=? WHERE object_id=?"))
+			{
+				ps.setInt(1, getSP());
+				ps.setInt(2, getObjectId());
+				ps.executeUpdate();
+			}
+			catch (SQLException e)
+			{
+				e.printStackTrace();
+			}
+	}
 
\ No newline at end of file

5) add the above methods and complete your request in your item handler something like that:

	@Override
	public void useItem(Playable playable, ItemInstance item, boolean forceUse)
	{
		if (!(playable instanceof Player))
			return;
		
		Player activeChar = (Player) playable;
		
		if (item.getSP() > 0)
		{
			activeChar.addExpAndSp(0, item.getSP());
			item.setSP(0, true);
			activeChar.destroyItem("SP", item, null, true);
		}
		else if (activeChar.getSp() > 0)
		{
			final int charSP = activeChar.getSp();
			activeChar.removeExpAndSp(0, charSP);
			item.setSP(charSP, true);
			activeChar.sendMessage(charSP + " saved!");
		}
		else
			activeChar.sendMessage("You do not have enough SP!");
	}

 

 

p.s i didnt test it

Edited by melron
Guest
This topic is now closed to further replies.
×
×
  • Create New...