Thread: NPCDrops always broken...

Page 1 of 2 12 LastLast
Results 1 to 10 of 11
  1. #1 NPCDrops always broken... 
    squared

    Join Date
    Jun 2013
    Posts
    355
    Thanks given
    38
    Thanks received
    27
    Rep Power
    30
    Could someone please explain to me why I always get this error when adding NPCconstants and drops? It always happens.

    Code:
    java.lang.ArrayIndexOutOfBound***ception: 1
    	at server.model.npcs.NPCDrops.loadDrops(NPCDrops.java:41)
    	at server.model.npcs.NPCDrops.<init>(NPCDrops.java:15)
    	at server.Server.<clinit>(Server.java:67)
    Just to let you know, I am doing the files correctly. NPCConstants is laid out as '1 526'
    NPCDrops is laid out as '1:20 995:4 995:6
    1381:1'


    I just don't understand it! I've been trying to fix for days now.
    Reply With Quote  
     

  2. #2  
    squared

    Join Date
    Jun 2013
    Posts
    355
    Thanks given
    38
    Thanks received
    27
    Rep Power
    30
    bump
    Reply With Quote  
     

  3. #3  
    need java lessons
    Eclipse's Avatar
    Join Date
    Aug 2012
    Posts
    4,436
    Thanks given
    686
    Thanks received
    898
    Rep Power
    490
    Use tabs and not spaces.

    Quote Originally Posted by jerryrocks317 View Post
    i am 14 and have my own laptop im on almost 24/7 currently creating rsps lol so please get off my thread lol
    Reply With Quote  
     

  4. #4  
    squared

    Join Date
    Jun 2013
    Posts
    355
    Thanks given
    38
    Thanks received
    27
    Rep Power
    30
    Quote Originally Posted by Ninth Legion View Post
    Use tabs and not spaces.
    I do use tabs. Anything else?
    Reply With Quote  
     

  5. #5  
    Registered Member
    Join Date
    Dec 2011
    Posts
    286
    Thanks given
    10
    Thanks received
    4
    Rep Power
    27
    Its out of the format..
    Reply With Quote  
     

  6. #6  
    Registered Member

    Join Date
    May 2013
    Age
    26
    Posts
    683
    Thanks given
    138
    Thanks received
    115
    Rep Power
    104
    Checkout NPCDrops.java and see if there something like a maximum of added NPCDrops.
    Reply With Quote  
     

  7. #7  
    squared

    Join Date
    Jun 2013
    Posts
    355
    Thanks given
    38
    Thanks received
    27
    Rep Power
    30
    Quote Originally Posted by Thee Mountain View Post
    Checkout NPCDrops.java and see if there something like a maximum of added NPCDrops.
    A maximum added NPCDrops? How would I go about finding this?
    Reply With Quote  
     

  8. #8  
    squared

    Join Date
    Jun 2013
    Posts
    355
    Thanks given
    38
    Thanks received
    27
    Rep Power
    30
    Quote Originally Posted by Mr Terror View Post
    Its out of the format..
    Out of format? How exactly?
    Reply With Quote  
     

  9. #9  
    Registered Member

    Join Date
    May 2013
    Age
    26
    Posts
    683
    Thanks given
    138
    Thanks received
    115
    Rep Power
    104
    Quote Originally Posted by c0nnr View Post
    A maximum added NPCDrops? How would I go about finding this?
    Well because you told us that the wrong was located in the classes and not in the txt files / config files etc, there has to be something in your class files that doesn't allow you to do the thing you want to do.
    Checkout what this is at NPCDrops.java at line 41 (It has to be there or something after or before, because you told us that you did everything right at the txt / config files).
    Reply With Quote  
     

  10. #10  
    squared

    Join Date
    Jun 2013
    Posts
    355
    Thanks given
    38
    Thanks received
    27
    Rep Power
    30
    Quote Originally Posted by Thee Mountain View Post
    Well because you told us that the wrong was located in the classes and not in the txt files / config files etc, there has to be something in your class files that doesn't allow you to do the thing you want to do.
    Checkout what this is at NPCDrops.java at line 41 (It has to be there or something after or before, because you told us that you did everything right at the txt / config files).
    This is my NPCDrops.java.

    Spoiler for code:
    package server.model.npcs;

    import java.io.File;
    import java.util.HashMap;
    import java.util.StringTokenizer;
    import java.util.Scanner;

    /**
    * @author Sanity
    */

    public class NPCDrops {

    public NPCDrops() {
    loadDrops();
    }

    public static HashMap<Integer, int[][]> normalDrops = new HashMap<Integer, int[][]>();
    public static HashMap<Integer, int[][]> rareDrops = new HashMap<Integer, int[][]>();
    public static HashMap<Integer, int[]> constantDrops = new HashMap<Integer, int[]>();
    public static HashMap<Integer, Integer> dropRarity = new HashMap<Integer, Integer>();

    public void loadDrops() {
    try {
    int[][][] npcDrops = new int[3800][][];
    int[][][] rareDrops2 = new int[3800][][];
    int[] itemRarity = new int[3800];
    File f = new File("./Data/cfg/NPCDrops.TSM");
    Scanner s = new Scanner(f);
    while (s.hasNextLine()) {
    String line = s.nextLine();
    if (line.startsWith("#"))
    continue;
    StringTokenizer normalTok = new StringTokenizer(line, "\t");
    line = s.nextLine();
    if (line.startsWith("#"))
    continue;
    StringTokenizer rareTok = new StringTokenizer(line, "\t");
    String[] information = normalTok.nextToken().split(":");
    int npcId = Integer.parseInt(information[0]);
    itemRarity[npcId] = Integer.parseInt(information[1]) - 1;
    npcDrops[npcId] = new int[normalTok.countTokens()][2];
    rareDrops2[npcId] = new int[rareTok.countTokens()][2];
    int count = 0;
    while (normalTok.hasMoreTokens()) {
    String[] temp = normalTok.nextToken().split(":");
    npcDrops[npcId][count][0] = Integer.parseInt(temp[0]);
    npcDrops[npcId][count][1] = Integer.parseInt(temp[1]);
    count++;
    }
    count = 0;
    while (rareTok.hasMoreTokens()) {
    String[] temp = rareTok.nextToken().split(":");
    rareDrops2[npcId][count][0] = Integer.parseInt(temp[0]);
    // System.out.println("Raredrop: " + count + " " +
    // rareDrops2[npcId][count][0]);
    rareDrops2[npcId][count][1] = Integer.parseInt(temp[1]);
    // System.out.println("Raredrop: " + count + " " +
    // rareDrops2[npcId][count][1]);
    count++;
    }
    normalDrops.put(npcId, npcDrops[npcId]);
    rareDrops.put(npcId, rareDrops2[npcId]);
    dropRarity.put(npcId, itemRarity[npcId]);
    }
    loadConstants();
    } catch (Exception e) {
    e.printStackTrace();
    }
    }

    public void loadConstants() {
    try {
    File f = new File("./Data/cfg/NpcConstants.TSM");
    Scanner s = new Scanner(f);
    while (s.hasNextLine()) {
    String line = s.nextLine();
    if (line.startsWith("#"))
    continue;
    StringTokenizer constantTok = new StringTokenizer(line, "\t");
    int npcId = Integer.parseInt(constantTok.nextToken());
    int count = 0;
    int[] temp = new int[constantTok.countTokens()];
    while (constantTok.hasMoreTokens()) {
    temp[count] = Integer.parseInt(constantTok.nextToken());
    count++;
    }
    constantDrops.put(npcId, temp);
    }
    } catch (Exception e) {
    e.printStackTrace();
    }

    }

    }
    Reply With Quote  
     

Page 1 of 2 12 LastLast

Thread Information
Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)


User Tag List

Similar Threads

  1. adding npcdrops the item.java way
    By fabjan in forum Tutorials
    Replies: 13
    Last Post: 03-29-2008, 11:00 PM
  2. Broken Barrows
    By Wiggy in forum Tutorials
    Replies: 9
    Last Post: 08-21-2007, 06:10 PM
  3. Always wondered.
    By Omegus in forum General
    Replies: 5
    Last Post: 08-02-2007, 07:38 PM
  4. [45*] Always talk in a Colour.
    By Impulser in forum RS2 Client
    Replies: 2
    Last Post: 05-21-2007, 10:58 PM
Posting Permissions
  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •