[HELP] DestroyItem
Forum rules
READ NOW: L2j Forums Rules of Conduct
READ NOW: L2j Forums Rules of Conduct
-
- Posts: 15
- Joined: Sun Mar 07, 2010 9:35 pm
[HELP] DestroyItem
hey ppl, I want to know how to destroy item from inventory... I know how to add an item:
L2ItemInstance item = ItemTable.getInstance().createItem("Rebirth Item", itemId3, count3, player);
player.getInventory().addItem("Rebirth Item3", item.getItemId(), count3, player, null);
So please dont shout at me, I searched for this, but didint find anything.
L2ItemInstance item = ItemTable.getInstance().createItem("Rebirth Item", itemId3, count3, player);
player.getInventory().addItem("Rebirth Item3", item.getItemId(), count3, player, null);
So please dont shout at me, I searched for this, but didint find anything.
-
- Posts: 1160
- Joined: Thu Aug 30, 2007 5:17 pm
Re: [HELP] DestroyItem
what you mean when in game just use the bin in your inventory
-
- Posts: 15
- Joined: Sun Mar 07, 2010 9:35 pm
Re: [HELP] DestroyItem
I am modifying RebirthMasterInstance code, and I dont know how to command server to destroy item in players inventory...
Code:
Code:
Code: Select all
package com.l2jserver.gameserver.model.actor.instance; import com.l2jserver.gameserver.datatables.ItemTable;import com.l2jserver.gameserver.model.L2ItemInstance;import com.l2jserver.gameserver.model.L2Skill;import com.l2jserver.gameserver.model.base.ClassId;import com.l2jserver.gameserver.model.base.Experience;import com.l2jserver.gameserver.network.SystemMessageId;import com.l2jserver.gameserver.network.serverpackets.SystemMessage;import com.l2jserver.gameserver.templates.chars.L2NpcTemplate; /**++ * Rebirth Npc's Instance++ * ++ * @author HanWik++ */ public class L2RebirthMasterInstance extends L2NpcInstance{ int itemId = 3470; int itemId2 = 3470; int itemId3 = 3470; int count = 1; int count2 = 10; int count3 = 33; int ItemNeededId = 57; int ItemNeededId2 = 57; int ItemNeededId3 = 57; int ItemNeededAmount = 1000000000; int ItemNeededAmount2 = 50000; int ItemNeededAmount3 = 10000000; int FirstReb = 0; int SecondReb = 1; int ThirdReb = 2; int MaxReb = 3; public L2RebirthMasterInstance(int objectId, L2NpcTemplate template) { super(objectId, template); } @Override public void onBypassFeedback(L2PcInstance player, String command) { if (command.startsWith("Rebirth")) { ClassId classId = player.getClassId(); int jobLevel = classId.level(); if (player.getLevel() >= 85 && jobLevel == 3 && player.getRebirths() == FirstReb) { L2ItemInstance ItemNeededId = player.getInventory().getItemByItemId(itemId); player.getInventory().destroyItem("Rebirth Engine", ItemNeededId, ItemNeededAmount, player, null); L2ItemInstance item = ItemTable.getInstance().createItem("Rebirth Item", itemId, count, player); player.getInventory().addItem("Rebirth Item", item.getItemId(), count, player, null); long pXp = player.getExp(); long tXp = Experience.LEVEL[1]; player.removeExpAndSp(pXp - tXp, 0); ClassId _baseClass = classId; for (ClassId child : ClassId.values()) { if (classId.childOf(child)) { _baseClass = child; for (ClassId child2 : ClassId.values()) { if (_baseClass.childOf(child2)) { _baseClass = child2; for (ClassId child3 : ClassId.values()) { if (_baseClass.childOf(child3)) _baseClass = child3; } } } } } for (L2Skill skill : player.getAllSkills()) player.removeSkill(skill); player.setClassId(_baseClass.getId()); if (player.isSubClassActive()) player.getSubClasses().get(player.getClassIndex()).setClassId(player.getActiveClass()); else player.setBaseClass(player.getActiveClass()); player.broadcastUserInfo(); player.rewardSkills(); player.sendSkillList(); // system sound for 1st and 2nd occupation player.sendPacket(new SystemMessage(SystemMessageId.CLASS_TRANSFER)); // Update the overloaded status of the L2PcInstance player.refreshOverloaded(); // Update the expertise status of the L2PcInstance player.refreshExpertisePenalty(); player.setRebirths(1); player.sendMessage("You have completed your first rebirth"); } else if (player.getLevel() >= 85 && jobLevel == 3 && player.getRebirths() == SecondReb) { L2ItemInstance item = ItemTable.getInstance().createItem("Rebirth Item", itemId2, count2, player); player.getInventory().addItem("Rebirth Item2", item.getItemId(), count2, player, null); long pXp = player.getExp(); long tXp = Experience.LEVEL[1]; player.removeExpAndSp(pXp - tXp, 0); ClassId _baseClass = classId; for (ClassId child : ClassId.values()) { if (classId.childOf(child)) { _baseClass = child; for (ClassId child2 : ClassId.values()) { if (_baseClass.childOf(child2)) { _baseClass = child2; for (ClassId child3 : ClassId.values()) { if (_baseClass.childOf(child3)) _baseClass = child3; } } } } } for (L2Skill skill : player.getAllSkills()) player.removeSkill(skill); player.setClassId(_baseClass.getId()); if (player.isSubClassActive()) player.getSubClasses().get(player.getClassIndex()).setClassId(player.getActiveClass()); else player.setBaseClass(player.getActiveClass()); player.broadcastUserInfo(); player.rewardSkills(); player.sendSkillList(); // system sound for 1st and 2nd occupation player.sendPacket(new SystemMessage(SystemMessageId.CLASS_TRANSFER)); // Update the overloaded status of the L2PcInstance player.refreshOverloaded(); // Update the expertise status of the L2PcInstance player.refreshExpertisePenalty(); player.setRebirths(2); player.sendMessage("You have completed your second rebirth"); } else if (player.getLevel() >= 85 && jobLevel == 3 && player.getRebirths() == ThirdReb) { L2ItemInstance item = ItemTable.getInstance().createItem("Rebirth Item", itemId3, count3, player); player.getInventory().addItem("Rebirth Item3", item.getItemId(), count3, player, null); long pXp = player.getExp(); long tXp = Experience.LEVEL[1]; player.removeExpAndSp(pXp - tXp, 0); ClassId _baseClass = classId; for (ClassId child : ClassId.values()) { if (classId.childOf(child)) { _baseClass = child; for (ClassId child2 : ClassId.values()) { if (_baseClass.childOf(child2)) { _baseClass = child2; for (ClassId child3 : ClassId.values()) { if (_baseClass.childOf(child3)) _baseClass = child3; } } } } } for (L2Skill skill : player.getAllSkills()) player.removeSkill(skill); player.setClassId(_baseClass.getId()); if (player.isSubClassActive()) player.getSubClasses().get(player.getClassIndex()).setClassId(player.getActiveClass()); else player.setBaseClass(player.getActiveClass()); player.broadcastUserInfo(); player.rewardSkills(); player.sendSkillList(); // system sound for 1st and 2nd occupation player.sendPacket(new SystemMessage(SystemMessageId.CLASS_TRANSFER)); // Update the overloaded status of the L2PcInstance player.refreshOverloaded(); // Update the expertise status of the L2PcInstance player.refreshExpertisePenalty(); player.setRebirths(3); player.sendMessage("You have completed your third rebirth"); } else if (player.getRebirths() == MaxReb) { player.sendMessage("You reached the maximum amount of rebirths"); } else if (player.getLevel() < 85) { player.sendMessage("You are to low level, you need to atleast be 85"); } else if (jobLevel < 3) { player.sendMessage("You can only be reborn when you have 3rd profession"); } else { player.sendMessage("Something is wrong, FAIL!"); } } } }
- jurchiks
- Posts: 6769
- Joined: Sat Sep 19, 2009 4:16 pm
- Location: Eastern Europe
Re: [HELP] DestroyItem
public void destroyItem(String process, L2ItemInstance item, L2PcInstance actor, L2Object reference)
can't find any with count...
Edit:
public boolean destroyItemByItemId(String process, int itemId, int count, L2Object reference, boolean sendMessage)
can't find any with count...
Edit:
public boolean destroyItemByItemId(String process, int itemId, int count, L2Object reference, boolean sendMessage)
If you have problems, FIRST TRY SOLVING THEM YOURSELF, and if you get errors, TRY TO ANALYZE THEM, and ONLY if you can't help it, THEN ask here.
Otherwise you will never learn anything if all you do is copy-paste!
Discussion breeds innovation.
Otherwise you will never learn anything if all you do is copy-paste!
Discussion breeds innovation.
- janiii
- L2j Veteran
- Posts: 4269
- Joined: Wed May 28, 2008 3:15 pm
- Location: Slovakia
Re: [HELP] DestroyItem
check L2PcInstance and all the methods destroyItem*
e.g.
or check PcInventory class for similar methods.
e.g.
Code: Select all
public boolean destroyItemByItemId(String process, int itemId, long count, L2Object reference, boolean sendMessage)public boolean destroyItemWithoutTrace(String process, int objectId, long count, L2Object reference, boolean sendMessage)public boolean destroyItem(String process, L2ItemInstance item, L2Object reference, boolean sendMessage)public boolean destroyItem(String process, L2ItemInstance item, long count, L2Object reference, boolean sendMessage)public boolean destroyItem(String process, int objectId, long count, L2Object reference, boolean sendMessage)
DO NOT EVEN TRY TO MESS WITH ME!
forum flOOder dancing dEVILoper ♀
I don't give private support - PM will be ignored!
forum flOOder dancing dEVILoper ♀
I don't give private support - PM will be ignored!
-
- Posts: 15
- Joined: Sun Mar 07, 2010 9:35 pm
Re: [HELP] DestroyItem
I know these methods, but I dont know how to make them work... ;/
If you checked my code, u saw that I tryed something with these methods, but that didint work.
If you checked my code, u saw that I tryed something with these methods, but that didint work.
- denser
- Posts: 1392
- Joined: Wed May 30, 2007 9:13 pm
- Location: Russia
- Contact:
Re: [HELP] DestroyItem
interesting...is it possible, janiii, to pres alt_g, inventory and drag to trash players item and destroy it ?))) it would be more useful for gm....
Tiger, once tasted human flesh, will want to taste it again
L2J - the place where glad to see you any time!
L2J - the place where glad to see you any time!
-
- Posts: 15
- Joined: Sun Mar 07, 2010 9:35 pm
Re: [HELP] DestroyItem
denser, I dont understand you...
- JIV
- L2j Veteran
- Posts: 1882
- Joined: Sun Jan 06, 2008 8:17 pm
- Location: Slovakia
- Contact:
Re: [HELP] DestroyItem
2denser: no you cant do that, since client dont send action on sever.
-
- Posts: 15
- Joined: Sun Mar 07, 2010 9:35 pm
Re: [HELP] DestroyItem
Please write ontopic... :/
- janiii
- L2j Veteran
- Posts: 4269
- Joined: Wed May 28, 2008 3:15 pm
- Location: Slovakia
Re: [HELP] DestroyItem
we already wrote you all the methods that exist to destroy an item. or just check other scripts (search all the scripts in your favourite file manager and search for "destroy" word in the files).Dae wrote:Please write ontopic... :/
DO NOT EVEN TRY TO MESS WITH ME!
forum flOOder dancing dEVILoper ♀
I don't give private support - PM will be ignored!
forum flOOder dancing dEVILoper ♀
I don't give private support - PM will be ignored!
-
- Posts: 15
- Joined: Sun Mar 07, 2010 9:35 pm
Re: [HELP] DestroyItem
Can u write me an example?
- jurchiks
- Posts: 6769
- Joined: Sat Sep 19, 2009 4:16 pm
- Location: Eastern Europe
Re: [HELP] DestroyItem
dude wtf? are you really that lazy? janiii just told you to search in existing scripts, there you will find more than enough examples!
data/scripts/custom/SkillTransfer/SkillTransfer.java
data/scripts/handlers/bypasshandlers/Loto.java
data/scripts/handlers/bypasshandlers/RideVyvern.java
data/scripts/handlers/bypasshandlers/TerritoryWar.java
...
data/scripts/custom/SkillTransfer/SkillTransfer.java
data/scripts/handlers/bypasshandlers/Loto.java
data/scripts/handlers/bypasshandlers/RideVyvern.java
data/scripts/handlers/bypasshandlers/TerritoryWar.java
...
If you have problems, FIRST TRY SOLVING THEM YOURSELF, and if you get errors, TRY TO ANALYZE THEM, and ONLY if you can't help it, THEN ask here.
Otherwise you will never learn anything if all you do is copy-paste!
Discussion breeds innovation.
Otherwise you will never learn anything if all you do is copy-paste!
Discussion breeds innovation.
-
- Posts: 15
- Joined: Sun Mar 07, 2010 9:35 pm
Re: [HELP] DestroyItem
I have another question, I found method that i needed:
player.destroyItemByItemId("rb", ItemNeededId, ItemNeededAmount, player, true);
Now when i press rebirth it destroys that item if I have it and rebirths me, but if i havent got that item he still rebirths me, my question would be how to make protection that if I dont have item i would not be reborned?
player.destroyItemByItemId("rb", ItemNeededId, ItemNeededAmount, player, true);
Now when i press rebirth it destroys that item if I have it and rebirths me, but if i havent got that item he still rebirths me, my question would be how to make protection that if I dont have item i would not be reborned?
- jurchiks
- Posts: 6769
- Joined: Sat Sep 19, 2009 4:16 pm
- Location: Eastern Europe
Re: [HELP] DestroyItem
if (!item.getItemId(ItemNeededId))
If you have problems, FIRST TRY SOLVING THEM YOURSELF, and if you get errors, TRY TO ANALYZE THEM, and ONLY if you can't help it, THEN ask here.
Otherwise you will never learn anything if all you do is copy-paste!
Discussion breeds innovation.
Otherwise you will never learn anything if all you do is copy-paste!
Discussion breeds innovation.