A Project for Chronicle 4 based on L2JServer.


    Hero Custom Item

    Share
    avatar
    dandiarena

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

    Hero Custom Item

    Post  dandiarena on 23rd October 2013, 22:44

    well i have this code to do hero you if you use it.

    But the problem its that if you relogin, or lose the conection the hero status gone.

    And i want to add some to do that the status stay to x days that you wany, but i dont do work this part.

    Code:

    // Custom Hero Item , When You Double Click On It , You Gain Hero Status
    // Source File Name:   HeroCustomItem.java

    package net.sf.l2j.gameserver.handler.itemhandlers;

    import net.sf.l2j.Config;
    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;
    import net.sf.l2j.gameserver.serverpackets.ActionFailed;
    import net.sf.l2j.gameserver.serverpackets.SocialAction;

    public class HeroCustomItem
        implements IItemHandler
    {

        public HeroCustomItem()
        {
        }

        public void useItem(L2PlayableInstance playable, L2ItemInstance item)
        {
           if (Config.HERO_CUSTOM_ITEMS)
          {
             if (!(playable instanceof L2PcInstance))
             {
                return;
             }
             
             L2PcInstance activeChar = (L2PcInstance) playable;
             
             if (!activeChar.isNoble() && Config.HERO_CUSTOM_ITEM_NOBLESS_NEEDED)
               {
                   activeChar.sendMessage("To be Hero, First you want to be Nobles!.");
                   return;
               }
             
             if (activeChar.isHero())
             {
                activeChar.sendMessage("Now You are Hero!.");
             } else
                {
                    activeChar.broadcastPacket(new SocialAction(activeChar.getObjectId(), 16));
                    activeChar.setHero(true);
                    activeChar.sendMessage("Now You are Hero.");
                    activeChar.broadcastUserInfo();
                    playable.destroyItem("Consume", item.getObjectId(), 1, null, false);
                }
            }
        }

        public int[] getItemIds()
        {
            return ITEM_IDS;
        }

       private static final int ITEM_IDS[] =
       {
          Config.HERO_CUSTOM_ITEM_ID
       };

    }

      Current date/time is 19th November 2017, 18:16