Page 1 of 1
Add an item to a character...
Posted: Mon Apr 30, 2007 1:55 am
by StarLess
Hello, I need your suggestion.
If I want to give an item to a character I can do /trade and give the item...
but sometime there is a particular item that it isn't exchange and with the /trade command I can't trade it..
there is some command like for example //add_item #itemID #count ?
thanks for your answer
StarLess
Posted: Thu May 17, 2007 2:06 pm
by slyce
If you know how to apply a patch to the java code of the l2jcore I can give you a mod for the //create_item command which I used on my server.
With this the item is created in the inventory of the target (or the GM if there is no valid target) so you have to be careful using it.
If you know a little bit about java you can rewrite this code and make a new command
Code: Select all
Index: C:/Workspace3.2/L2_GameServer_It/java/net/sf/l2j/gameserver/handler/admincommandhandlers/AdminCreateItem.java
===================================================================
--- C:/Workspace3.2/L2_GameServer_It/java/net/sf/l2j/gameserver/handler/admincommandhandlers/AdminCreateItem.java (revision 833)
+++ C:/Workspace3.2/L2_GameServer_It/java/net/sf/l2j/gameserver/handler/admincommandhandlers/AdminCreateItem.java (working copy)
@@ -24,6 +24,7 @@
import net.sf.l2j.Config;
import net.sf.l2j.gameserver.handler.IAdminCommandHandler;
import net.sf.l2j.gameserver.model.GMAudit;
+import net.sf.l2j.gameserver.model.L2Object;
import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
import net.sf.l2j.gameserver.serverpackets.ItemList;
import net.sf.l2j.gameserver.serverpackets.NpcHtmlMessage;
@@ -104,13 +105,27 @@
private void createItem(L2PcInstance activeChar, int id, int num)
{
- activeChar.getInventory().addItem("Admin", id, num, activeChar, null);
+ L2Object target = activeChar.getTarget();
+ L2PcInstance player = null;
+ if (target instanceof L2PcInstance)
+ {
+ player = (L2PcInstance)target;
+ }
+ else
+ {
+ SystemMessage sm = new SystemMessage(614);
+ sm.addString("Incorrect target.");
+ activeChar.sendPacket(sm);
+ return;
+ }
+
+ player.getInventory().addItem("Admin", id, num, activeChar, null);
ItemList il = new ItemList(activeChar, true);
activeChar.sendPacket(il);
SystemMessage sm = new SystemMessage(614);
- sm.addString("You have spawned " + num + " item(s) number " + id + " in your inventory.");
+ sm.addString("You have spawned " + num + " item(s) number " + id + " in " + player.getName() + "'s inventory.");
activeChar.sendPacket(sm);
NpcHtmlMessage adminReply = new NpcHtmlMessage(5);
@@ -122,7 +137,7 @@
replyMSG.append("</tr></table>");
replyMSG.append("<br><br>");
replyMSG.append("<table width=270><tr><td>Item Creation Complete.<br></td></tr></table>");
- replyMSG.append("<table width=270><tr><td>You have spawned " + num + " item(s) number " + id + " in your inventory.</td></tr></table>");
+ replyMSG.append("<table width=270><tr><td>You have spawned " + num + " item(s) number " + id + " in " + player.getName() + "'s inventory.</td></tr></table>");
replyMSG.append("</body></html>");
adminReply.setHtml(replyMSG.toString());
Posted: Fri Jun 29, 2007 9:05 am
by BLACK-PANTHERS
command delete item to a character...