Item names can be checked through item definitions (and they can be matched up with there ID) can they not?
|
|

Well, a while ago I posted an Item Searching method for 667. The one for 667 would not work for 718, so I just made this really quick. It's nothing special or extraordinary, but it works, so I'm happy with it. What this does is search a text file for related names to what you type. Can be partial names, full names, whatever. I've also found a text file in a server that was formatted the way i needed it.
I've monitored RAM while typing this like 5 times with a large amount of results, and RAM was not dramatically increased (it actually wasn't affected at all.) Simple because it doesn't load the file, it just reads it (from what i can tell..lul) Well anyway, Don't Hate. here it is:
Code:package com.rs.game.player.content.custom; import java.io.IOException; import com.rs.cache.loaders.ItemDefinitions.FileUtilities; import com.rs.game.player.Player; public class ItemDatabase { public static void search(Player p, String name) { String itemName = name.toLowerCase(); int results = 0; try { for (String lines : FileUtilities.readFile("./data/ItemList.txt")) { String[] data = lines.split(" - "); if (lines.toLowerCase().contains(itemName)) { results++; if (results > 250) { p.getPackets().consoleMessage("Found 250+ results. Only 250 are shown."); return; } p.getPackets().consoleMessage("<col=00FF00>"+data[0]+"</col> - "+data[1]+""); } } p.getPackets().consoleMessage("<col=FF0000>Found "+results+" matches for '"+itemName+"'</col>."); } catch (IOException e) { e.printStackTrace(); } return; } }Item List Download: [Only registered and activated users can see links. ]Code:if (cmd[0].equals("getid")) { String itemName = ""; for (int i = 1; i < cmd.length; i++) itemName += cmd[i] + ((i == cmd.length - 1) ? "" : " "); ItemDatabase.search(player, itemName); }
PS: name might need changed![]()


Your other one worked for my 718 o.O

Cool![]()


obviously it wouldnt work... definitions are loaded on demand dumbas <.<.

So my method wouldn't work for my 718, but works for his? Makes sense i guess.......
Oh well, Ternary Operator posted one much better than searching a text file, but either one works all the same. Gets an item name and id number >.>
| « Node System | How to find modelId's of npc's. 718+ » |
| Thread Information |
Users Browsing this ThreadThere are currently 1 users browsing this thread. (0 members and 1 guests) |