masone Posted July 10, 2015 Share Posted July 10, 2015 package ru.catssoftware.gameserver.handler.itemhandler; import org.apache.log4j.Logger; import ru.catssoftware.gameserver.ThreadPoolManager; import ru.catssoftware.gameserver.datatables.NpcTable; import ru.catssoftware.gameserver.handler.IItemHandler; import ru.catssoftware.gameserver.idfactory.IdFactory; import ru.catssoftware.gameserver.model.L2ItemInstance; import ru.catssoftware.gameserver.model.actor.instance.L2NpcInstance; import ru.catssoftware.gameserver.model.actor.instance.L2PcInstance; import ru.catssoftware.gameserver.model.actor.instance.L2PlayableInstance; import ru.catssoftware.gameserver.network.SystemMessageId; import ru.catssoftware.gameserver.templates.chars.L2NpcTemplate; /** * Created by IntelliJ IDEA. * User: masone * Date: 02.07.15 * Time: 20:07 * To change this template use File | Settings | File Templates. */ public class spawnitem implements IItemHandler { protected static Logger _log = Logger.getLogger(spawnitem.class.getName()); private static final int[] ITEM_IDS = { 6673 }; public void useItem(L2PlayableInstance playable, L2ItemInstance item, boolean par){} public int[] getItemIds() { return ITEM_IDS; } public void useItem(L2PlayableInstance playable, L2ItemInstance item) { _log.info("use item" +item); L2PcInstance activeChar; activeChar = (L2PcInstance) playable; L2NpcTemplate template; template = NpcTable.getInstance().getTemplate(60000); if (activeChar.isInOlympiadMode()) { activeChar.sendPacket(SystemMessageId.THIS_ITEM_IS_NOT_AVAILABLE_FOR_THE_OLYMPIAD_EVENT); return; } //TODO flood protector L2NpcInstance npc = new L2NpcInstance(IdFactory.getInstance().getNextId(), template); npc.setInstanceId(activeChar.getInstanceId()); npc.setIsInvul(true); npc.setTitle(activeChar.getName()); npc.setName("masone"); npc.updateAbnormalEffect(); npc.spawnMe(activeChar.getX(), activeChar.getY(), activeChar.getZ()); ThreadPoolManager.getInstance().scheduleGeneral(new deleteNPC(npc), 60000); // activeChar.destroyItem("Summon", item.getObjectId(), 1, null, true); } public class deleteNPC implements Runnable { protected L2NpcInstance _npc; public void run() { _npc.deleteMe(); } deleteNPC(L2NpcInstance npc) { _npc = npc; } } } Quote Link to comment Share on other sites More sharing options...
pirama Posted July 10, 2015 Share Posted July 10, 2015 nice share ty :P Quote Link to comment Share on other sites More sharing options...
mardok Posted September 20, 2015 Share Posted September 20, 2015 anyone tested? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.