Thread: Find Item Id and Npc Id Commands

Page 1 of 2 12 LastLast
Results 1 to 10 of 12
  1. #1 Find Item Id and Npc Id Commands 
    Registered Member
    Core's Avatar
    Join Date
    Sep 2007
    Posts
    4,194
    Thanks given
    11
    Thanks received
    393
    Rep Power
    1985
    These commands use the lists already in your server files and is a lot quicker to use IMO then going to your lists and doing ctrl + f to find the item id you want or npc id you want, etc.

    Here is the first command, ::finditem "Item Name"
    Searches for any item name that contains the word you input.

    Here is the second command, ::findnpc "Npc Name"
    Searches for any npc name that contains the word you input.

    Item Id Finder:
    Code:
    if (playerCommand.startsWith("finditem")) {
    	try {
    		String item = playerCommand.substring(9).toLowerCase();
    		String itemName = "";
    		int totalItemsFound = 0;
    		boolean noFoundItems = true;
    		c.sendMessage("Searching item database for item names containing the word '"+item+"'...");
    		for(int i = 0; i < Config.ITEM_LIMIT; i++) {
    			if(Server.itemHandler.ItemList[i] != null) {
    				itemName = Server.itemHandler.ItemList[i].itemName.replaceAll("_", " ").toLowerCase();;
    				if(itemName.contains(item) || itemName.startsWith(item) || itemName.endsWith(item) || itemName.equalsIgnoreCase(item)) {
    					c.sendMessage(Server.itemHandler.ItemList[i].itemName+", ID: "+Server.itemHandler.ItemList[i].itemId);
    					totalItemsFound++;
    					noFoundItems = false;
    				}
    			}
    		}
    		if(noFoundItems)
    			c.sendMessage("Could not find any item names containing the word '"+item+"'.");
    		else
    			c.sendMessage("Found "+totalItemsFound+" item names containing the word '"+item+"'.");
    		
    	} catch(Exception e) {
    	}
    }
    Npc Id Finder:
    Code:
    if (playerCommand.startsWith("findnpc")) {
    	try {
    		String npc = playerCommand.substring(8).toLowerCase();
    		String npcName = "";
    		int totalNpcsFound = 0;
    		boolean noFoundNpcs = true;
    		c.sendMessage("Searching npc database for npc names containing the word '"+npc+"'...");
    		for(int i = 0; i < Server.npcHandler.maxListedNPCs; i++) {
    			if(Server.npcHandler.NpcList[i] != null) {
    				npcName = Server.npcHandler.NpcList[i].npcName.replaceAll("_", " ").toLowerCase();
    				if(npcName.contains(npc) || npcName.startsWith(npc) || npcName.endsWith(npc) || npcName.equalsIgnoreCase(npc)) {
    					c.sendMessage(Server.npcHandler.NpcList[i].npcName.replaceAll("_", " ")+", ID: "+Server.npcHandler.NpcList[i].npcId);
    					totalNpcsFound++;
    					noFoundNpcs = false;
    				}
    			}
    		}
    		if(noFoundNpcs)
    			c.sendMessage("Could not find any npc names containing the word '"+npc+"'.");
    		else
    			c.sendMessage("Found "+totalNpcsFound+" npc names containing the word'"+npc+"'.");
    		
    	} catch(Exception e) {
    	}
    }

    NOTE:
    This can spam up your chat box if you search for non specific things like 'sword'.
    Reply With Quote  
     

  2. #2  
    Registered Member
    Nikita's Avatar
    Join Date
    Aug 2008
    Age
    26
    Posts
    818
    Thanks given
    180
    Thanks received
    88
    Rep Power
    86
    You can dump all you're item / npcs ids from cache? Well looks good to me anyway!

    RoonScape
    Reply With Quote  
     

  3. #3  
    Member

    Join Date
    May 2008
    Posts
    1,288
    Thanks given
    50
    Thanks received
    92
    Rep Power
    0
    You could always rip the item search feature in the 377 client and add it to 317, it uses the chat box to display results like g/e.
    Reply With Quote  
     

  4. #4  
    Registered Member
    Core's Avatar
    Join Date
    Sep 2007
    Posts
    4,194
    Thanks given
    11
    Thanks received
    393
    Rep Power
    1985
    Why would you want to when you already have all the data being loaded from your CFG files? This is taking the data from Item.cfg and npc.cfg.
    Reply With Quote  
     

  5. #5  
    Member

    Join Date
    May 2008
    Posts
    1,288
    Thanks given
    50
    Thanks received
    92
    Rep Power
    0
    Quote Originally Posted by Core View Post
    Why would you want to when you already have all the data being loaded from your CFG files? This is taking the data from Item.cfg and npc.cfg.
    Because if you do it client-sided then you can have it show a preview of the item like on the grand exchange.

    Here's what I was using (converted from the 377 client-sided method to be used server-sided)
    Code:
        public void searchItems(String input)
        {
    	final int MAX_RESULTS = 80;
    	int itemSearchResultCount = 0;
    	String[] results = new String[MAX_RESULTS];
    	int[] ids = new int[MAX_RESULTS];
    	for(Item item : PlayerItems.itemCache){
    	    if(item == null){
    		continue;
    	    }
    	    if(item.untradable && playerRights < 2){
    		continue;
    	    }
    	    if(item.name != null && item.name.toLowerCase().contains(input)){
    	    	results[itemSearchResultCount] = item.name;
    	    	ids[itemSearchResultCount] = item.id;
    	    	itemSearchResultCount++;
    	    }
    	    if(itemSearchResultCount >= results.length){
    	    	break;
    	    }
    	}
    	for(int i = 0; i < results.length; i++){
    	    if(results[i] == null){
    		continue;
    	    }
    	    String name = results[i];
    	    int id = ids[i];
    	    sendMessage(name + " [" + id + "] " + (isNoted(id) ? "(Noted)" : ""));
    	}
    	if(itemSearchResultCount == 0){
    	    sendMessage("No matching items found, please shorten search.");
    	} else {
    	    sendMessage("Search returned " + itemSearchResultCount + " matches for '" + input + "'.");
    	}
        }
    Reply With Quote  
     

  6. #6  
    Registered Member
    Core's Avatar
    Join Date
    Sep 2007
    Posts
    4,194
    Thanks given
    11
    Thanks received
    393
    Rep Power
    1985
    Quote Originally Posted by Clifton View Post
    Because if you do it client-sided then you can have it show a preview of the item like on the grand exchange.

    Here's what I was using (converted from the 377 client-sided method to be used server-sided)
    Code:
        public void searchItems(String input)
        {
    	final int MAX_RESULTS = 80;
    	int itemSearchResultCount = 0;
    	String[] results = new String[MAX_RESULTS];
    	int[] ids = new int[MAX_RESULTS];
    	for(Item item : PlayerItems.itemCache){
    	    if(item == null){
    		continue;
    	    }
    	    if(item.untradable && playerRights < 2){
    		continue;
    	    }
    	    if(item.name != null && item.name.toLowerCase().contains(input)){
    	    	results[itemSearchResultCount] = item.name;
    	    	ids[itemSearchResultCount] = item.id;
    	    	itemSearchResultCount++;
    	    }
    	    if(itemSearchResultCount >= results.length){
    	    	break;
    	    }
    	}
    	for(int i = 0; i < results.length; i++){
    	    if(results[i] == null){
    		continue;
    	    }
    	    String name = results[i];
    	    int id = ids[i];
    	    sendMessage(name + " [" + id + "] " + (isNoted(id) ? "(Noted)" : ""));
    	}
    	if(itemSearchResultCount == 0){
    	    sendMessage("No matching items found, please shorten search.");
    	} else {
    	    sendMessage("Search returned " + itemSearchResultCount + " matches for '" + input + "'.");
    	}
        }
    Oh lol sorry didn't fully read your reply, just woke up.

    Or something a lot easier is make a simple interface with a scroll bar and use the simple sendInterfaceItem packet on the interface.
    Reply With Quote  
     

  7. #7  
    Registered Member

    Join Date
    Feb 2010
    Posts
    3,187
    Thanks given
    1,124
    Thanks received
    834
    Discord
    View profile
    Rep Power
    1514
    Nice job.

    Maybe someone will find this usefull when making a pking server.
    Reply With Quote  
     

  8. #8  
    Registered Member
    Core's Avatar
    Join Date
    Sep 2007
    Posts
    4,194
    Thanks given
    11
    Thanks received
    393
    Rep Power
    1985
    Quote Originally Posted by Fire Cape View Post
    Nice job.

    Maybe someone will find this usefull when making a pking server.
    Or any server programmer that is creating there server and needs to test a variety of items and npcs like one usually does when making a server.
    Reply With Quote  
     

  9. #9  
    Super Donator

    Benji's Avatar
    Join Date
    Feb 2010
    Age
    26
    Posts
    1,526
    Thanks given
    920
    Thanks received
    501
    Discord
    View profile
    Rep Power
    555
    this is a great idea.

    Reply With Quote  
     

  10. #10  
    Registered Member
    Core's Avatar
    Join Date
    Sep 2007
    Posts
    4,194
    Thanks given
    11
    Thanks received
    393
    Rep Power
    1985
    Quote Originally Posted by /*Benjiboyyy*/ View Post
    this is a great idea.
    Thanks, I was just trying to think one of the most convenient ways to find certain ids for creating and thought why do you even have to leave your server and go to a list to find it, just type in a simple command.
    Reply With Quote  
     

  11. Thankful user:


Page 1 of 2 12 LastLast

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
  •