A Project for Chronicle 4 based on L2JServer.


    Hero item java coded

    Share
    avatar
    jamaica

    Posts : 135
    Join date : 2013-02-24
    Age : 28
    Location : Romania

    Hero item java coded

    Post  jamaica on 8th August 2013, 21:29

    Code:
    ### Eclipse Workspace Patch 1.0
    #P Lisvus_GameServer
    Index: java/net/sf/l2j/gameserver/handler/itemhandlers/HeroItem.java
    ===================================================================
    --- java/net/sf/l2j/gameserver/handler/itemhandlers/HeroItem.java (revision 0)
    +++ java/net/sf/l2j/gameserver/handler/itemhandlers/HeroItem.java (working copy)
    @@ -0,0 +1,58 @@
    +
    +/*
    + * This program is free software: you can redistribute it and/or modify it under
    + * the terms of the GNU General Public License as published by the Free Software
    + * Foundation, either version 3 of the License, or (at your option) any later
    + * version.
    + *
    + * This program is distributed in the hope that it will be useful, but WITHOUT
    + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
    + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
    + * details.
    + *
    + * You should have received a copy of the GNU General Public License along with
    + * this program. If not, see <http://www.gnu.org/licenses/>.
    + */
    +package net.sf.l2j.gameserver.handler.itemhandlers;
    +
    +import net.sf.l2j.gameserver.handler.IItemHandler;
    +import net.sf.l2j.gameserver.model.L2ItemInstance;
    +import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
    +import net.sf.l2j.gameserver.model.actor.instance.L2PlayableInstance;
    +
    +/**
    + * @author HanWik
    + */
    +public class HeroItem implements IItemHandler
    +{
    + private static final int[] ITEM_IDS =
    + {
    + 5556
    + };
    +
    + @Override
    + public void useItem(L2PlayableInstance playable, L2ItemInstance item)
    + {
    + if (!(playable instanceof L2PcInstance))
    + {
    + return;
    + }
    + L2PcInstance activeChar = (L2PcInstance) playable;
    + int itemId = item.getItemId();
    +
    + if (itemId == 5556) // Item to become hero
    + {
    + activeChar.setHero(true);
    + activeChar.broadcastUserInfo();
    + }
    + }
    +
    + /**
    + * @see net.sf.l2j.gameserver.handler.IItemHandler#getItemIds()
    + */
    + @Override
    + public int[] getItemIds()
    + {
    + return ITEM_IDS;
    + }
    +}
    avatar
    dandiarena

    Posts : 95
    Join date : 2013-06-20
    Age : 26
    Location : Argentina

    Re: Hero item java coded

    Post  dandiarena on 8th October 2013, 18:13

    jamaica wrote:
    Code:
    ### Eclipse Workspace Patch 1.0
    #P Lisvus_GameServer
    Index: java/net/sf/l2j/gameserver/handler/itemhandlers/HeroItem.java
    ===================================================================
    --- java/net/sf/l2j/gameserver/handler/itemhandlers/HeroItem.java (revision 0)
    +++ java/net/sf/l2j/gameserver/handler/itemhandlers/HeroItem.java (working copy)
    @@ -0,0 +1,58 @@
    +
    +/*
    + * This program is free software: you can redistribute it and/or modify it under
    + * the terms of the GNU General Public License as published by the Free Software
    + * Foundation, either version 3 of the License, or (at your option) any later
    + * version.
    + *
    + * This program is distributed in the hope that it will be useful, but WITHOUT
    + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
    + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
    + * details.
    + *
    + * You should have received a copy of the GNU General Public License along with
    + * this program. If not, see <http://www.gnu.org/licenses/>.
    + */
    +package net.sf.l2j.gameserver.handler.itemhandlers;
    +
    +import net.sf.l2j.gameserver.handler.IItemHandler;
    +import net.sf.l2j.gameserver.model.L2ItemInstance;
    +import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
    +import net.sf.l2j.gameserver.model.actor.instance.L2PlayableInstance;
    +
    +/**
    + * @author HanWik
    + */
    +public class HeroItem implements IItemHandler
    +{
    + private static final int[] ITEM_IDS =
    + {
    + 5556
    + };
    +
    + @Override
    + public void useItem(L2PlayableInstance playable, L2ItemInstance item)
    + {
    + if (!(playable instanceof L2PcInstance))
    + {
    + return;
    + }
    + L2PcInstance activeChar = (L2PcInstance) playable;
    + int itemId = item.getItemId();
    +
    + if (itemId == 5556) // Item to become hero
    + {
    + activeChar.setHero(true);
    + activeChar.broadcastUserInfo();
    + }
    + }
    +
    + /**
    + * @see net.sf.l2j.gameserver.handler.IItemHandler#getItemIds()
    + */
    + @Override
    + public int[] getItemIds()
    + {
    + return ITEM_IDS;
    + }
    +}
    thiss work but i have a problem, the item that came hero dont delete, when you restart your hero its gone, but no the item i can you use it again
    avatar
    jamaica

    Posts : 135
    Join date : 2013-02-24
    Age : 28
    Location : Romania

    Re: Hero item java coded

    Post  jamaica on 8th October 2013, 21:39

    add the red line and ur problem is fixed


    activeChar.setHero(true);
    activeChar.broadcastUserInfo();


    playable.destroyItem("Item has disappear", item.getObjectId(), 1, null, false);
    avatar
    dandiarena

    Posts : 95
    Join date : 2013-06-20
    Age : 26
    Location : Argentina

    Re: Hero item java coded

    Post  dandiarena on 12th October 2013, 21:29

    its works, but how you can get that this hero stay more time, that do relogin and stay keep the status hero. because if you do restart the hero its gone.

    Sponsored content

    Re: Hero item java coded

    Post  Sponsored content


      Current date/time is 24th September 2017, 09:48