Thread: What is wong?

Results 1 to 5 of 5
  1. #1 What is wong? 
    Registered Member Hexagon's Avatar
    Join Date
    May 2008
    Posts
    672
    Thanks given
    28
    Thanks received
    18
    Rep Power
    33
    why my server don't let me put exp on skill 21?

    every time i add it dces me BUT it add the exp

    the error:
    Code:
    Loaded WorldMap In (62 ms)...
    SERVERNAME
    [client-1-Fr0zen fury]: Loading Process Completed  [Has powers, lag: 0 ms]
    [client-1-Fr0zen fury]: ab=153
    Exception encountered while parsing incoming packets from Fr0zen fury.
    java.lang.ArrayIndexOutOfBoundsException: 21
            at client.addSkillXP(client.java:6042)
            at client.customCommand(client.java:8791)
            at client.parseIncomingPackets(client.java:15835)
            at client.packetProcess(client.java:17620)
            at PlayerHandler.process(PlayerHandler.java:271)
            at process.run(process.java:23)
            at java.lang.Thread.run(Unknown Source)
    ClientHandler: Client Fr0zen fury disconnected (localhost)
    [client-1-Fr0zen fury]: Loading Process Completed  [Has powers, lag: 0 ms]

    addskillxp boolean:
    Spoiler for boolean:

    public boolean addSkillXP(int amount, int skill) {
    if (randomed) {
    sM("You must answer the genie before you can gain experience!");
    return false;
    }
    if ((amount + playerXP[skill]) < 0 || amount + playerXP[skill] > 200000000 || playerXP[skill] >= 200000000) {
    playerXP[skill] = 200000000;
    refreshSkills();
    return false;
    }
    int oldLevel = getLevelForXP(playerXP[skill]);
    playerXP[skill] += amount;
    if (oldLevel < getLevelForXP(playerXP[skill])) {
    specGFX(199);
    playerLevel[skill] = getLevelForXP(playerXP[skill]);
    updateRequired = true;
    appearanceUpdateRequired = true;
    sM("Congratulations, you just advanced a "
    + statName[skill] + " level.");
    getTotalLevel();
    if (playerLevel[skill] > 98)
    capetrim +=1;
    if (playerLevel[skill] > 90)
    setSkillLevel(skill, playerLevel[skill], playerXP[skill]);
    }
    refreshSkills();
    // setSkillLevel(skill, playerLevel[skill], playerXP[skill]);
    if (skill == 2) {
    CalculateMaxHit();
    }
    return true;
    }
    Reply With Quote  
     

  2. #2  
    Registered Member
    Its paris's Avatar
    Join Date
    Apr 2009
    Posts
    1,141
    Thanks given
    56
    Thanks received
    234
    Rep Power
    689
    remember that when you have an array, it starts with 0.
    So if there are 21 skills, and skill is your skillnumber.
    Skill would go from 0 to 20 in playerXP[skill].
    If you want the 21st skill, you should use 20 instead of 21.
    Same with statName[skill].
    Reply With Quote  
     

  3. #3  
    Registered Member Hexagon's Avatar
    Join Date
    May 2008
    Posts
    672
    Thanks given
    28
    Thanks received
    18
    Rep Power
    33
    thanks but where i change it? in getLevelForXP(playerXP[skill]) method?
    Reply With Quote  
     

  4. #4  
    Registered Member
    Its paris's Avatar
    Join Date
    Apr 2009
    Posts
    1,141
    Thanks given
    56
    Thanks received
    234
    Rep Power
    689
    My guess is u used a command, look there where it assigned the skillnumber and make sure the lowest skillnumber is 0 and the highest, the amount of skills - 1 (probably 20 since 21 gave an arrayoutofboundsexception).
    Reply With Quote  
     

  5. #5  
    Registered Member Hexagon's Avatar
    Join Date
    May 2008
    Posts
    672
    Thanks given
    28
    Thanks received
    18
    Rep Power
    33
    well it will be hunt for the array =\

    EDIT: found what it was... was the string with skillnames... it didn't had my custom skill =]
    Reply With Quote  
     


Thread Information
Users Browsing this Thread

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


User Tag List

Posting Permissions
  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •