Thread: what kind of error is this?

Results 1 to 10 of 10
  1. #1 what kind of error is this? 
    Registered Member
    Join Date
    Jan 2012
    Posts
    134
    Thanks given
    2
    Thanks received
    0
    Rep Power
    10
    Code:
    [2/17/17 3:51 PM]: java.lang.ArrayIndexOutOfBoundsException: 101
    [2/17/17 3:51 PM]:      at server.model.shops.ShopAssistant.addShopItem(ShopAssistant.java:637)
    [2/17/17 3:51 PM]:      at server.model.shops.ShopAssistant.sellItem(ShopAssistant.java:601)
    [2/17/17 3:51 PM]:      at server.model.players.packets.Bank5.processPacket(Bank5.java:23)
    [2/17/17 3:51 PM]:      at server.model.players.PacketHandler.processPacket(PacketHandler.java:137)
    [2/17/17 3:51 PM]:      at server.model.players.Client.processQueuedPackets(Client.java:1900)
    [2/17/17 3:51 PM]:      at server.model.players.PlayerHandler.process(PlayerHandler.java:149)
    [2/17/17 3:51 PM]:      at server.Server.main(Server.java:186)
    this is in the server when i try to sell an item after attempting to add sell x
    Reply With Quote  
     

  2. #2  
    Community Veteran

    mige5's Avatar
    Join Date
    Aug 2008
    Posts
    5,528
    Thanks given
    573
    Thanks received
    1,410
    Rep Power
    2114
    its an index out of bounds exception, says it on the very first line.
    Number of page #1 releases with most views & posts: (Updated: 2023)
    RS2 server section: 1
    RS2 client section: 2
    Reply With Quote  
     

  3. Thankful user:


  4. #3  
    Registered Member
    Join Date
    Jan 2012
    Posts
    134
    Thanks given
    2
    Thanks received
    0
    Rep Power
    10
    would you happen to know how to fix this? i dont get this error on my test servers but for some reason on this one i do get it
    Reply With Quote  
     

  5. #4  
    Respected Member


    George's Avatar
    Join Date
    Mar 2009
    Posts
    7,099
    Thanks given
    2,226
    Thanks received
    3,146
    Rep Power
    5000
    U tryna access an array with an identifier that's > the arrays length
    Attached image

    Spoiler for Spoilers!:
    Attached image
    Attached image
    Attached image
    Attached image
    Reply With Quote  
     

  6. Thankful user:


  7. #5  
    Community Veteran

    mige5's Avatar
    Join Date
    Aug 2008
    Posts
    5,528
    Thanks given
    573
    Thanks received
    1,410
    Rep Power
    2114
    Quote Originally Posted by ownerdivine View Post
    would you happen to know how to fix this? i dont get this error on my test servers but for some reason on this one i do get it
    Number of page #1 releases with most views & posts: (Updated: 2023)
    RS2 server section: 1
    RS2 client section: 2
    Reply With Quote  
     


  8. #6  
    Registered Member
    Join Date
    Dec 2016
    Posts
    87
    Thanks given
    1
    Thanks received
    4
    Rep Power
    59
    Post your code at server.model.shops.ShopAssistant.addShopItem(ShopA ssistant.java:637) and I can attempt to assist you. Basically what is happening is that you have an array of example 12 elements, you try add a 13th element and that's the error you will receive. So from the looks of it, you are trying to input an index that is out of bounds of the array.
    Reply With Quote  
     

  9. #7  
    Why you reading this?

    LoveandPower's Avatar
    Join Date
    Sep 2010
    Posts
    2,166
    Thanks given
    907
    Thanks received
    288
    Rep Power
    390
    It's real simple ... whatever your issue is with shops...
    Well you see here is the thing...you first need to understand what an array is in general terms

    http://docs.oracle.com/javase/tutori...ts/arrays.html

    amazing what you can find from a google search

    http://docs.oracle.com/javase/7/docs...-external=true

    public class ArrayIndexOutOfBoundsException
    extends IndexOutOfBoundsException
    Thrown to indicate that an array has been accessed with an illegal index. The index is either negative or greater than or equal to the size of the array.
    Spoiler for sig too large:


    Reply With Quote  
     

  10. #8  
    Registered Member
    Join Date
    Jan 2012
    Posts
    134
    Thanks given
    2
    Thanks received
    0
    Rep Power
    10
    Quote Originally Posted by Jmusic View Post
    Post your code at server.model.shops.ShopAssistant.addShopItem(ShopA ssistant.java:637) and I can attempt to assist you. Basically what is happening is that you have an array of example 12 elements, you try add a 13th element and that's the error you will receive. So from the looks of it, you are trying to input an index that is out of bounds of the array.
    Code:
    public boolean addShopItem(int itemID, int amount) {
    		boolean Added = false;
    		if (amount <= 0) {
    			return false;
    		}
    		if (Item.itemIsNote[itemID] == true) {
    			itemID = c.getItems().getUnnotedItem(itemID);
    		}
    		for (int i = 0; i < Server.shopHandler.ShopItems.length; i++) {
    			if ((Server.shopHandler.ShopItems[c.myShopId][i] - 1) == itemID) {
    				Server.shopHandler.ShopItemsN[c.myShopId][i] += amount;
    				Added = true;
    			}
    		}
    		if (Added == false) {
    			for (int i = 0; i < Server.shopHandler.ShopItems.length; i++) {
    				if (Server.shopHandler.ShopItems[c.myShopId][i] == 0) {
    					Server.shopHandler.ShopItems[c.myShopId][i] = (itemID + 1);
    					Server.shopHandler.ShopItemsN[c.myShopId][i] = amount;
    					Server.shopHandler.ShopItemsDelay[c.myShopId][i] = 0;
    					break;
    				}
    			}
    		}
    		return true;
    	}
    Reply With Quote  
     

  11. #9  
    Registered Member
    Join Date
    Dec 2016
    Posts
    87
    Thanks given
    1
    Thanks received
    4
    Rep Power
    59
    Okay I have a few questions before I could try assist you.
    - Did you write this piece of code?
    - Is ShopItems.length the amount of items in a shop?
    - Where are you calling this method from and what values are you inserting in the method parameters?

    Haven't coded rsps before so don't know the classes.
    Reply With Quote  
     

  12. #10  
    Community Veteran


    Arch337's Avatar
    Join Date
    Sep 2008
    Posts
    2,950
    Thanks given
    210
    Thanks received
    349
    Rep Power
    1376
    Are you trying to sell an item in a full shop or just any shop?


    "A fail act is something you do regular, but a dumb act is something you can learn from"
    Spoiler for Problem?:
    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

Similar Threads

  1. What kind of obfuscation is this?
    By Poesy700 in forum Help
    Replies: 4
    Last Post: 01-19-2014, 10:36 AM
  2. 718, What kind of error is this?
    By King Aj in forum Help
    Replies: 4
    Last Post: 01-12-2013, 05:35 PM
  3. [562] What type of error is this?
    By Melvin in forum Help
    Replies: 0
    Last Post: 12-06-2011, 09:33 PM
  4. What kind of car is this?
    By gnarly in forum Spam
    Replies: 4
    Last Post: 06-18-2011, 09:18 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
  •