Editing Customed Npc [help]

[CENTER]I can’t add a weapon nor shield to this customed npc.
I don’t understand why I get these errors thrown. Help please?

java.lang.ArrayIndexOutOfBoundsException: 7 You have Too many npcs at NPCDef.forID(NPCDef.java:579) at Client.updateNPCMovement(Client.java:5465) at Client.updateNPCs(Client.java:4640) at Client.parsePacket(Client.java:17618) at Client.mainGameProcessor(Client.java:6372) at Client.processGameLoop(Client.java:5495) at RSApplet.run(RSApplet.java:222) at Client.run(Client.java:8737) at java.lang.Thread.run(Unknown Source) java.lang.RuntimeException: eeeeeek at Client.updateNPCAmount(Client.java:15818) at Client.updateNPCs(Client.java:4639) at Client.parsePacket(Client.java:17618) at Client.mainGameProcessor(Client.java:6372) at Client.processGameLoop(Client.java:5495) at RSApplet.run(RSApplet.java:222) at Client.run(Client.java:8737) at java.lang.Thread.run(Unknown Source) You have Too many npcs java.lang.RuntimeException: eeeeeek at Client.updateNPCAmount(Client.java:15818) at Client.updateNPCs(Client.java:4639) at Client.parsePacket(Client.java:17618) at Client.mainGameProcessor(Client.java:6372) at Client.processGameLoop(Client.java:5495) at RSApplet.run(RSApplet.java:222) at Client.run(Client.java:8737) at java.lang.Thread.run(Unknown Source)

case 2580: npc.name = "King"; npc.combatLevel = 1234; npc.actions = new String[5]; npc.actions[1] = "Attack"; npc.models = new int[7]; npc.models[0] = 55007; //head npc.models[1] = 55011; //body npc.models[2] = 55009; //legs //npc.models[3] = 62575; //cape npc.models[4] = 13319; //ammy npc.models[5] = 14623; //boots npc.models[6] = 20147; //gloves npc.models[7] = 80044; //weapon npc.models[8] = 77568; //shield npc.standAnim = 808; npc.walkAnim = 819; npc.npcHeadModels = NPCDef.forID(517).npcHeadModels; break;
[URL=https://imageshack.com/i/pmBChePqp][/URL][/CENTER]

i mean it said on the second line that you have “Too many npcs”

You declared the size of the array incorrectly.
That’s why.

npc.models = new int[7];
You make the array a size of 7.
That means the values can only go in:
[0], [1], [2], [3], [4], [5], [6].

Yet, in your code, you’re accessing higher indexes:

npc.models[7] = 80044; //weapon npc.models[8] = 77568; //shield
This would be why you’re getting an ArrayIndexOutOfBoundException with the value of 7.
Because 7 is actually the eighth index, and your array is sized for 7, not 8, nor 9.

That doesn’t make sense to how this helps.

[quote=“sk8rdude461, post:3, topic:555081”]You declared the size of the array incorrectly.
That’s why.

npc.models = new int[7];
You make the array a size of 7.
That means the values can only go in:
[0], [1], [2], [3], [4], [5], [6].

Yet, in your code, you’re accessing higher indexes:

npc.models[7] = 80044; //weapon npc.models[8] = 77568; //shield
This would be why you’re getting an ArrayIndexOutOfBoundException with the value of 7.
Because 7 is actually the eighth index, and your array is sized for 7, not 8, nor 9.[/quote]

Thank you, sorry I didn’t get to reply earlier. Nonetheless, I didn’t see that array for some reason and I’m glad you responded quick.