might be 'memberscrolls' but if not, just use ctrl h on eclipse and search for 10943, so you can see where and how its done.
|
Hello everyone I am currently working with the Ruse/Necrotic release and I am wondering if someone can tell me where I might find the custom clue scroll codes like if I want to make my own? I have found it in 2 places but not sure where to get the actual code for what it does when redeemed.
might be 'memberscrolls' but if not, just use ctrl h on eclipse and search for 10943, so you can see where and how its done.
So I did some adding and im sure i got it wrong but this is everything that i got and the error.
items.txt
I did 22694 because that is the most amount of items or something my server can haveCode:Item Id: 22694 Name: Master Scroll Examine: Max all skills in Mordscape. Value: 0 Stackable: false Noted: false Double-handed: false Equipment type: WEAPON Is Weapon: false finish
MemberScrolls.java
And then in my rsps when I do ::item 22694 1 i Dont get the item there is a pic below and then the error.Code:case 25066: for (Skill skill : Skill.values()) { player.getInventory().delete(item, 1); int level = SkillManager.getMaxAchievingLevel(skill); player.getSkillManager().setCurrentLevel(skill, level).setMaxLevel(skill, level).setExperience(skill, SkillManager.getExperienceForLevel(level == 120 ? 120 : 99)); break; }
Code:java.lang.ArrayIndexOutOfBoundsException: 22694 at com.ruse.model.definitions.ItemDefinition.forId(ItemDefinition.java:118) at com.ruse.model.container.ItemContainer.add(ItemContainer.java:508) at com.ruse.net.packet.impl.CommandPacketListener.ownerCommands(CommandPacketListener.java:1466) at com.ruse.net.packet.impl.CommandPacketListener.handleMessage(CommandPacketListener.java:127) at com.ruse.net.PlayerSession.handleInputMessage(PlayerSession.java:111) at com.ruse.net.PlayerSession.handleQueuedMessages(PlayerSession.java:93) at com.ruse.world.entity.updating.PlayerUpdateSequence.executePreUpdate(PlayerUpdateSequence.java:34) at com.ruse.world.entity.updating.PlayerUpdateSequence.executePreUpdate(PlayerUpdateSequence.java:1) at com.ruse.world.entity.impl.CharacterList.forEach(CharacterList.java:148) at com.ruse.world.World.sequence(World.java:182) at com.ruse.engine.GameEngine.run(GameEngine.java:48) at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source) at java.util.concurrent.FutureTask.runAndReset(Unknown Source) at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(Unknown Source) at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(Unknown Source) at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) at java.lang.Thread.run(Unknown Source)
The exception you're getting is telling you the index you're trying to access in the item definition array doesn't exist. Looks like you need to up the array size up by one to fix this.
I'm not familiar with the "source" you are using, could you paste the contents of ItemDefinition.java?
There's a few things you can take away from that error code.
This tells you the value that you gave is too high of a value and exceeds the size of the array it was accessing.Code:java.lang.ArrayIndexOutOfBoundsException: 22694
- The next 11 lines in this case (this can differ) are all the lines that have to do with your source.
- These 11 lines are in order of most recently executed. It begins on the bottom line and ends on the top line.
Your first line is
Judging by the name i'd say that's a bit too early in the code so we'll start a bit higher.Code:at com.ruse.engine.GameEngine.run(GameEngine.java:48)
The below looks good i'd say even that forth line is probably useless, but I'm not sure what you send from Command List to Owner List.
Code:at com.ruse.model.definitions.ItemDefinition.forId(ItemDefinition.java:118) at com.ruse.model.container.ItemContainer.add(ItemContainer.java:508) at com.ruse.net.packet.impl.CommandPacketListener.ownerCommands(CommandPacketListener.java:1466) at com.ruse.net.packet.impl.CommandPacketListener.handleMessage(CommandPacketListener.java:127)
Now you should be able to read these errors on what they are saying. In this case from bottom to top we are doing the following:
- Class: CommandPacketListener , Method: handleMessage , Line 127 Called Next Method.
- Class: CommandPacketListener , Method: ownerCommands , Line 1466 Called Next Method.
- Class: ItemContainer , Method: add , Line 508 Called Next Method.
- Class: ItemDefinition , Method: forId , Line 118 Fails Execution at this line for Array Out Of Bounds Exception.
With the above i'd get all the methods for each of those lines as that includes the full process. You'll probably find additional code beyond that but it would give you more insight on the problem you are facing.
I wonder if i didnt put the item into the game properly? I mean above is all I have done and im completely new to this stuff so im not 100% sure if i did it properly. @Sub belowe it the ItemDefinition.java
Code:package com.ruse.model.definitions; import java.io.BufferedReader; import java.io.File; import java.io.FileReader; import java.io.IOException; import com.ruse.model.container.impl.Equipment; /** * This file manages every item definition, which includes * their name, description, value, skill requirements, etc. * * @author relex lawl */ public class ItemDefinition { /** * The directory in which item definitions are found. */ private static final String FILE_DIRECTORY = "./data/def/txt/items.txt"; /** * The max amount of items that will be loaded. */ private static final int MAX_AMOUNT_OF_ITEMS = 22694; /** * ItemDefinition array containing all items' definition values. */ private static ItemDefinition[] definitions = new ItemDefinition[MAX_AMOUNT_OF_ITEMS]; /** * Loading all item definitions */ public static void init() { ItemDefinition definition = definitions[0]; try { File file = new File(FILE_DIRECTORY); BufferedReader reader = new BufferedReader(new FileReader(file)); String line; while ((line = reader.readLine()) != null) { if (line.contains("inish")) { definitions[definition.id] = definition; continue; } String[] args = line.split(": "); if (args.length <= 1) continue; String token = args[0], value = args[1]; if (line.contains("Bonus[")) { String[] other = line.split("]"); int index = Integer.valueOf(line.substring(6, other[0].length())); double bonus = Double.valueOf(value); definition.bonus[index] = bonus; continue; } if (line.contains("Requirement[")) { String[] other = line.split("]"); int index = Integer.valueOf(line.substring(12, other[0].length())); int requirement = Integer.valueOf(value); definition.requirement[index] = requirement; continue; } switch (token.toLowerCase()) { case "item id": int id = Integer.valueOf(value); definition = new ItemDefinition(); definition.id = id; break; case "name": if(value == null) continue; definition.name = value; break; case "examine": definition.description = value; break; case "value": int price = Integer.valueOf(value); definition.value = price; break; case "stackable": definition.stackable = Boolean.valueOf(value); break; case "noted": definition.noted = Boolean.valueOf(value); break; case "double-handed": definition.isTwoHanded = Boolean.valueOf(value); break; case "equipment type": definition.equipmentType = EquipmentType.valueOf(value); break; case "is weapon": definition.weapon = Boolean.valueOf(value); break; } } reader.close(); } catch (IOException e) { e.printStackTrace(); } } public static ItemDefinition[] getDefinitions() { return definitions; } /** * Gets the item definition correspondent to the id. * * @param id The id of the item to fetch definition for. * @return definitions[id]. */ public static ItemDefinition forId(int id) { return (id < 0 || id > definitions.length || definitions[id] == null) ? new ItemDefinition() : definitions[id]; } /** * Gets the max amount of items that will be loaded * in Niobe. * @return The maximum amount of item definitions loaded. */ public static int getMaxAmountOfItems() { return MAX_AMOUNT_OF_ITEMS; } /** * The id of the item. */ private int id = 0; /** * Gets the item's id. * * @return id. */ public int getId() { return id; } /** * The name of the item. */ private String name = "None"; /** * Gets the item's name. * * @return name. */ public String getName() { return name; } /** * The item's description. */ private String description = "Null"; /** * Gets the item's description. * * @return description. */ public String getDescription() { return description; } /** * Flag to check if item is stackable. */ private boolean stackable; /** * Checks if the item is stackable. * * @return stackable. */ public boolean isStackable() { if(noted) return true; return stackable; } /** * The item's shop value. */ private int value; /** * Gets the item's shop value. * * @return value. */ public int getValue() { return isNoted() ? ItemDefinition.forId(getId() - 1).value : value; } /** * Gets the item's equipment slot index. * * @return equipmentSlot. */ public int getEquipmentSlot() { return equipmentType.slot; } /** * Flag that checks if item is noted. */ private boolean noted; /** * Checks if item is noted. * * @return noted. */ public boolean isNoted() { return noted; } private boolean isTwoHanded; /** * Checks if item is two-handed */ public boolean isTwoHanded() { return isTwoHanded; } private boolean weapon; public boolean isWeapon() { return weapon; } private EquipmentType equipmentType = EquipmentType.WEAPON; public EquipmentType getEquipmentType() { return equipmentType; } /** * Checks if item is full body. */ public boolean isFullBody() { return equipmentType.equals(EquipmentType.PLATEBODY); } /** * Checks if item is full helm. */ public boolean isFullHelm() { return equipmentType.equals(EquipmentType.FULL_HELMET); } private double[] bonus = new double[18]; public double[] getBonus() { return bonus; } private int[] requirement = new int[25]; public int[] getRequirement() { return requirement; } private enum EquipmentType { HAT(Equipment.HEAD_SLOT), CAPE(Equipment.CAPE_SLOT), SHIELD(Equipment.SHIELD_SLOT), GLOVES(Equipment.HANDS_SLOT), BOOTS(Equipment.FEET_SLOT), AMULET(Equipment.AMULET_SLOT), RING(Equipment.RING_SLOT), ARROWS(Equipment.AMMUNITION_SLOT), FULL_MASK(Equipment.HEAD_SLOT), FULL_HELMET(Equipment.HEAD_SLOT), BODY(Equipment.BODY_SLOT), PLATEBODY(Equipment.BODY_SLOT), LEGS(Equipment.LEG_SLOT), WEAPON(Equipment.WEAPON_SLOT); private EquipmentType(int slot) { this.slot = slot; } private int slot; } @Override public String toString() { return "[ItemDefinition(" + id + ")] - Name: " + name + "; equipment slot: " + getEquipmentSlot() + "; value: " + value + "; stackable ? " + Boolean.toString(stackable) + "; noted ? " + Boolean.toString(noted) + "; 2h ? " + isTwoHanded; } public static int getItemId(String itemName) { for (int i = 0; i < MAX_AMOUNT_OF_ITEMS; i++) { if (definitions[i] != null) { if (definitions[i].getName().equalsIgnoreCase(itemName)) { return definitions[i].getId(); } } } return -1; } }
Well ID 22694 is higher then your array length.
When you create an array it's starts from 0 not 1.
I.e.
int[] values = new int[100];
This would range from 0 to 99. If you count from 0 to 99 with your fingers or even just to 9 you'll find you use all 10 fingers.
However looking at your code something looks off slightly.. so try changing the below code.
Code:public static ItemDefinition forId(int id) { return (id < 0 || id > definitions.length || definitions[id] == null) ? new ItemDefinition() : definitions[id]; }
to the following:
Definition[0] should be that skeleton item from Dwarf's Cannon quest it's the generic NULL item people use as it has no real purpose and 0 is the default initialization value for integers and the start of an array so it won't cause out of array exceptions like -1 does.Code:public static ItemDefinition forId(int id) { if (id < 0 || id > definition.length) { System.out.println("[Item Definition]: Out Of Bounds at Index: " + id); return definitions[0]; } if (defintions[id] == null) { System.out.println("[Item Definition]: Index Isn't Loaded " + id); return definitions[0]; } return definitions[id]; }
Well the only reason that the id is set to 22694 is that it told me thats the max and i figured nothing else would have that ID so thats what i used. Also that bit of code as some errors and not to sure what to do with it?
change definition to definitions
Sadly enough this one stays with an error?
i did the create local variable but did nothing
« Previous Thread | Next Thread » |
Thread Information |
Users Browsing this ThreadThere are currently 1 users browsing this thread. (0 members and 1 guests) |