A Project for Chronicle 4 based on L2JServer.


    Custom Start Item

    Share
    avatar
    dandiarena

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

    Custom Start Item

    Post  dandiarena on 1st November 2013, 15:27

    To adapt:

    Code:

    index: /trunk/L2J-Game/config/main/custom.properties
    ===================================================================
    --- /trunk/L2J-Game/config/main/custom.properties (revision 1639)
    +++ /trunk/L2J-Game/config/main/custom.properties (revision 1680)
    @@ -266,2 +266,9 @@
     PvpRewardItemName = Adena
     PvpRewardAmmount = 100
    +
    +# Allow custom starter items?
    +AllowCustomStarterItems = false
    +
    +# You must allow custom starter items!
    +# Usage: id,count;id,count;
    +CustomStarterItems = 57,1000;
    Index: /trunk/L2J-Game/src/main/java/net/l2jserver/gameserver/network/clientpackets/CharacterCreate.java
    ===================================================================
    --- /trunk/L2J-Game/src/main/java/net/l2jserver/gameserver/network/clientpackets/CharacterCreate.java (revision 1634)
    +++ /trunk/L2J-Game/src/main/java/net/l2jserver/gameserver/network/clientpackets/CharacterCreate.java (revision 1680)
    @@ -19,4 +19,5 @@
     import net.sf.l2j.gameserver.datatables.CharNameTable;
     import net.sf.l2j.gameserver.datatables.CharTemplateTable;
    +import net.sf.l2j.gameserver.datatables.ItemTable;
     import net.sf.l2j.gameserver.datatables.SkillTable;
     import net.sf.l2j.gameserver.datatables.SkillTreeTable;
    @@ -29,4 +30,5 @@
     import net.sf.l2j.gameserver.model.L2World;
     import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
    +import net.sf.l2j.gameserver.model.itemcontainer.PcInventory;
     import net.sf.l2j.gameserver.model.quest.Quest;
     import net.sf.l2j.gameserver.model.quest.QuestState;
    @@ -154,4 +156,27 @@
           if (Config.STARTING_AA > 0)
              newChar.addAncientAdena("Init", Config.STARTING_AA, null, false);
    +      
    +      // L2EMU_CUSTOM - START
    +      for (int[] startingItems : Config.CUSTOM_STARTER_ITEMS)
    +      {
    +         if (newChar == null)
    +         {
    +            continue;
    +         }
    +         PcInventory inv = newChar.getInventory();
    +         if (ItemTable.getInstance().createDummyItem(startingItems[0]).isStackable())
    +         {
    +            inv.addItem("Starter Items", startingItems[0], startingItems[1], newChar, null);
    +         }
    +         else
    +         {
    +            for (int i = 0; i < startingItems[1]; i++)
    +            {
    +               inv.addItem("Starter Items", startingItems[0], 1, newChar, null);
    +            }
    +         }
    +      }
    +      // L2EMU_CUSTOM - END
    +      
           //L2EMU_ADD
           newChar.getPosition().setXYZInvisible(template.getSpawnX(), template.getSpawnY(), template.getSpawnZ());
    Index: /trunk/L2J-Game/src/main/java/net/l2jserver/Config.java
    ===================================================================
    --- /trunk/L2J-Game/src/main/java/net/l2jserver/Config.java (revision 1664)
    +++ /trunk/L2J-Game/src/main/java/net/l2jserver/Config.java (revision 1680)
    @@ -25,4 +25,5 @@
     import java.math.BigInteger;
     import java.util.ArrayList;
    +import java.util.List;
     import java.util.Map;
     import java.util.Properties;
    @@ -867,4 +868,7 @@
        public static String        PVP_REWARD_ITEM_NAME;
        public static int           PVP_REWARD_ITEM_AMMOUNT;
    +   
    +   public static boolean      ALLOW_CUSTOM_STARTER_ITEMS;
    +   public static List<int[]>    CUSTOM_STARTER_ITEMS = new FastList<int[]>();
     
        //*********************************************************
    @@ -940,4 +944,36 @@
               PVP_REWARD_ITEM_NAME = customSettings.getProperty("PvpRewardItemName", "Adena");
               PVP_REWARD_ITEM_AMMOUNT = Integer.parseInt(customSettings.getProperty("PvpRewardAmmount", "100"));
    +          ALLOW_CUSTOM_STARTER_ITEMS = Boolean.parseBoolean(customSettings.getProperty("AllowCustomStarterItems", "false"));
    +      
    +          
    +         if (ALLOW_CUSTOM_STARTER_ITEMS)
    +         {
    +             String[] propertySplit = customSettings.getProperty("CustomStarterItems", "0,0").split(";");
    +             for (String starteritems : propertySplit)
    +             {
    +                String[] starteritemsSplit = starteritems.split(",");
    +                if (starteritemsSplit.length != 2)
    +                {
    +                   ALLOW_CUSTOM_STARTER_ITEMS = false;
    +                   System.out.println("StarterItems[Config.load()]: invalid config property -> starter items \""+ starteritems + "\"");
    +                }
    +                else
    +                {
    +                try
    +                {
    +                  CUSTOM_STARTER_ITEMS.add(new int[] { Integer.valueOf(starteritemsSplit[0]), Integer.valueOf(starteritemsSplit[1]) });
    +                }
    +                   catch (NumberFormatException nfe)
    +                   {
    +                      if (!starteritems.equals(""))
    +                      {
    +                         ALLOW_CUSTOM_STARTER_ITEMS = false;
    +                         System.out.println("StarterItems[Config.load()]: invalid config property -> starter items \"" + starteritems + "\"");
    +                      }
    +                   }
    +                }
    +             }
    +         }
    +          
           }
           catch (Exception e)

    xbacox2010

    Posts : 41
    Join date : 2013-10-20

    Re: Custom Start Item

    Post  xbacox2010 on 2nd November 2013, 09:20

    Code:
    -- this sql updates db to make diff intial items.
    update char_templates set `items1`= 27 where `ClassName` in ( 'Human Fighter','Elf Fighter','DE Fighter','Orc Fighter','Dwarf Fighter','Male Soldier','Female Soldier'); -- chest/ bone breast plate
    update char_templates set `items2`= 33 where `ClassName` in ( 'Human Fighter','Elf Fighter','DE Fighter','Orc Fighter','Dwarf Fighter','Male Soldier','Female Soldier'); --  legs/ bone gaiters
    update char_templates set `items3`= 219 where `ClassName` in ( 'Human Fighter','Elf Fighter','DE Fighter','Orc Fighter','Dwarf Fighter','Male Soldier','Female Soldier'); --  sword breaker
    update char_templates set `items4`= 38 where `ClassName` in ( 'Human Fighter','Elf Fighter','DE Fighter','Orc Fighter','Dwarf Fighter','Male Soldier','Female Soldier'); -- low boots
    update char_templates set `items5`= 5250 where `ClassName` in ( 'Human Fighter','Elf Fighter','DE Fighter','Orc Fighter','Dwarf Fighter','Male Soldier','Female Soldier'); --  Greater Compressed Package of Soulshots: No-grade

    update char_templates set `items1`= 1101 where `ClassName` in ('Human Mage','Elf Mage','DE Mage','Orc Mage'); -- tunic of devotion
    update char_templates set `items2`= 1104 where `ClassName` in ('Human Mage','Elf Mage','DE Mage','Orc Mage'); -- stocking of devotion
    update char_templates set `items3`= 100 where `ClassName` in ('Human Mage','Elf Mage','DE Mage','Orc Mage');  -- voodo dool
    update char_templates set `items4`= 44 where `ClassName` in ('Human Mage','Elf Mage','DE Mage','Orc Mage');  -- leather helmet
    update char_templates set `items5`= 5262 where `ClassName` in ('Human Mage','Elf Mage','DE Mage','Orc Mage'); -- Greater Compressed Package of Blessed Spiritshots:  No-grade
    Try with this example..you not need jave code for set items to start..
    avatar
    dandiarena

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

    Re: Custom Start Item

    Post  dandiarena on 2nd November 2013, 14:07

    No thanks, i dont search this

    Sponsored content

    Re: Custom Start Item

    Post  Sponsored content


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