Thread: Requesting 718 Matrix GetItem ID command

Results 1 to 2 of 2
  1. #1 Requesting 718 Matrix GetItem ID command 
    Registered Member
    Join Date
    Mar 2017
    Posts
    5
    Thanks given
    0
    Thanks received
    0
    Rep Power
    0
    so I have been looking in my server for a getid command and I don't have it if anyone can help me with a thread it would be helpful it is for matrix 718
    Reply With Quote  
     

  2. #2  
    Registered Member Inoxent's Avatar
    Join Date
    Jul 2012
    Age
    31
    Posts
    98
    Thanks given
    8
    Thanks received
    1
    Rep Power
    11
    rs/game/player/content

    ItemSearch.java

    Code:
    package com.rs.game.player.content;
    
    import java.util.ArrayList;
    
    import com.rs.game.item.Item;
    import com.rs.game.player.Player;
    import com.rs.utils.Utils;
    
    public class ItemSearch {
    
        public static int[] COMPONENTS = { 30, 32, 34, 36, 38, 49, 51, 53, 55, 57, 59, 62, 64, 66, 68, 70, 72, 74, 76, 190, 79, 81, 83, 85, 88, 90, 92, 94, 97, 99, 101, 104, 106, 108, 110, 115, 117, 119, 121, 123, 125, 131, 127, 129, 2, 159, 173, 175, 177, 182, 184, 186, 188 };
    
        public static void searchForItem(Player player, String itemName) {
            ArrayList<String> ITEMS = new ArrayList<String>();
    
            player.getInterfaceManager().sendInterface(1082);
            
            for (int i = 0; i < Utils.getInterfaceDefinitionsComponentsSize(1082); i++) {
                player.getPackets().sendIComponentText(1082, i, "");
            }
            player.getPackets().sendIComponentText(1082, 159, "Item Search List for item" + Utils.formatPlayerNameForDisplay(itemName) +".");
            player.getPackets().sendIComponentText(1082, 41, "Item Name");
            player.getPackets().sendIComponentText(1082, 42, "ItemId");
            
            for (int i = 0; i < Utils.getItemDefinitionsSize(); i++) {
                Item item = new Item(i);
                if (item.getDefinitions().getName().toLowerCase().contains(itemName.toLowerCase())) {
                    ITEMS.add(item.getName() + (item.getDefinitions().isNoted() ? "(noted)," : ",") + item.getId());
                }
            }
            
            if (ITEMS.size() < 54/*53*/) {
                String name = "NULL";
                String id = "-1";
                for (int i = 0; i < ITEMS.size(); i++) {
                    name = ITEMS.get(i).split(",")[0];
                    id = ITEMS.get(i).split(",")[1];
                    player.getPackets().sendIComponentText(1082, COMPONENTS[i], Utils.formatPlayerNameForDisplay(name));
                    player.getPackets().sendIComponentText(1082, COMPONENTS[i] + 1, id);
                }
                player.getPackets().sendIComponentText(1082, 11, "Found " + ITEMS.size() + " results for the item " + Utils.formatPlayerNameForDisplay(itemName) + ".");
            } else {
                player.getPackets().sendIComponentText(1082, 11, "Found to many results for the item " + Utils.formatPlayerNameForDisplay(itemName) + ". Refine your search.");
            }
        }
    
    }

    Then in commands.java

    Imports:

    com.rs.game.player.content.ItemSearch;

    And add the command where your item command is:

    Code:
                case "getid":
                    name = "";
                    for (int i = 1; i < cmd.length; i++)
                        name += cmd[i] + ((i == cmd.length - 1) ? "" : " ");
                    ItemSearch.searchForItem(player, name);
                    return true;
    and here's a little extra a command fusion of the item and the itemn commands that way you won't need to use the itemn when you don't remember the id very usefull since the getid command does not show all the item ids

    Code:
            case "item":
                if (cmd.length < 2) {
                    player.getPackets().sendGameMessage(
                            "Use: ::item id/name (optional:amount can only be used if spawning using item ID)");
                        return true;
                } try {
                    if (!player.canSpawn()) {
                        player.getPackets().sendGameMessage(
                                "You can't spawn while you're in this area.");
                        return true;
                    }
                    int itemId = Integer.valueOf(cmd[1]);
                    ItemDefinitions defs = ItemDefinitions
                            .getItemDefinitions(itemId);
                    if (defs.isLended())
                        return true;
                    if (defs.isOverSized()) {
                        player.getPackets().sendGameMessage("The item appears to be oversized.");
                        return true;
                    }
                    name = defs == null ? "" : defs.getName()
                            .toLowerCase();
                    if (name.contains("Sacred clay")) {
                        return true;
                    }
                    if(name.toLowerCase().contains("donator") || name.toLowerCase().contains("basket of eggs") || name.toLowerCase().contains("sled")) {
                        player.getDialogueManager().startDialogue("SimpleMessage", "This items can only be earned in the Member Refuge of Fear minigame.");
                        return true;
                    }
                    for (String string : Settings.UNSPAWNABLE_ITEMS) {
                        if (!(player.getRights() == 2) && name.contains(string)) {
                            player.getPackets().sendGameMessage(
                                    "You need to be admin to spawn " + name
                                    + " or get the item as a drop from a monster.");
                            return true;
                        }
                    }
                    for (String string : Settings.MEMBER_ITEMS) {
                        if (name.contains(string) && !player.isMember() && !player.isMonthMember()) {
                            player.getPackets().sendGameMessage(
                                    "You need to be Member to spawn item " + name +".");
                            return true;
                        }
                    }
                    for (String string : Settings.OWNER_ONLY_ITEMS) {
                        if (name.contains(string) && !player.getUsername().equalsIgnoreCase("")) {
                            player.getPackets().sendGameMessage(
                                    "You must be  to use " + name + ".");
                            return true;
                        }
                    }
                    for (String string : Settings.STAFF_ONLY_ITEMS) {
                        if (!(player.getRights() == 2) && name.contains(string)) {
                            player.getPackets().sendGameMessage(
                                    "You need to be Admin to spawn " + name
                                    + ".");
                            return true;
                        }
                    }
                    for (String string : Settings.EARNED_ITEMS) {
                        if (name.contains(string) && (!(player.getRights() == 2))) {
                            player.getPackets().sendGameMessage(
                                    "You must earn " + name + ".");
                            return true;
                        }
                    }
                            player.getInventory().addItem(itemId,
                                    cmd.length >= 3 ? Integer.valueOf(cmd[2]) : 1);
                            player.stopAll();
                            player.getPackets().sendGameMessage("Found item: " + itemId + ".");
                    } catch (NumberFormatException e) {
                        player.getPackets().sendGameMessage(
                                "Use: ::item id/name (optional:amount can only be used if spawning using item ID)");
                        }
                    StringBuilder sb = new StringBuilder(cmd[1]);
                        int amount = 1;
                        if (cmd.length > 2) {
                            for (int i = 2; i < cmd.length; i++) {
                                if (cmd[i].startsWith("+")) {
                                    amount = Integer.parseInt(cmd[i].replace("+", ""));
                                } else {
                                    sb.append(" ").append(cmd[i]);
                                }
                            }
                        }
                    String name1 = sb.toString().toLowerCase().replace("[", "(")
                            .replace("]", ")").replaceAll(",", "'");
                    if (name1.contains("Sacred clay")) {
                        return true;
                    }
                    if(name1.toLowerCase().contains("donator") || name1.toLowerCase().contains("basket of eggs") || name1.toLowerCase().contains("sled")) {
                        player.getDialogueManager().startDialogue("SimpleMessage", "This items can only be earned in the Member Refuge of Fear minigame.");
                        return true;
                    }
                    for (String string : Settings.UNSPAWNABLE_ITEMS) {
                        if (!(player.getRights() == 2) && name1.contains(string)) {
                            player.getPackets().sendGameMessage(
                                    "You need to be admin to spawn " + name1
                                    + " or get the item as a drop from a monster.");
                            return true;
                        }
                    }
                    for (String string : Settings.MEMBER_ITEMS) {
                        if (name1.contains(string) && !player.isMember() && !player.isMonthMember()) {
                            player.getPackets().sendGameMessage(
                                    "You need to be Member to spawn item " + name1 +".");
                            return true;
                        }
                    }
                    for (String string : Settings.OWNER_ONLY_ITEMS) {
                        if (name1.contains(string) && !player.getUsername().equalsIgnoreCase("")) {
                            player.getPackets().sendGameMessage(
                                    "You must be  to use " + name1 + ".");
                            return true;
                        }
                    }
                    for (String string : Settings.STAFF_ONLY_ITEMS) {
                        if (!(player.getRights() == 2) && name1.contains(string)) {
                            player.getPackets().sendGameMessage(
                                    "You need to be Admin to spawn " + name1
                                    + ".");
                            return true;
                        }
                    }
                    for (String string : Settings.EARNED_ITEMS) {
                        if (name1.contains(string) && (!(player.getRights() == 2))) {
                            player.getPackets().sendGameMessage(
                                    "You must earn " + name1 + ".");
                            return true;
                        }
                    }
                    for (int i = 0; i < Utils.getItemDefinitionsSize(); i++) {
                        ItemDefinitions def = ItemDefinitions
                                .getItemDefinitions(i);
                        if (def.getName().toLowerCase().equalsIgnoreCase(name1)) {
                            player.getInventory().addItem(i, amount);
                            player.stopAll();
                            player.getPackets().sendGameMessage("Found item " + name1 + " - id: " + i + ".");
                            return true;
                        }
                    }
                    player.getPackets().sendGameMessage(
                            "Could not find item by the name " + name1 + ".");
                return true;
    When spawing by the item id it will say it can not find the item by name and will show the id but it will always find the item unless it is not added

    P.S.: You might have some errors due to the String string : Settings. because most 718 do not have the String string : Settings.MEMBER_ITEMS, String string : Settings.OWNER_ONLY_ITEMS, String string : Settings.STAFF_ONLY_ITEMS and String string : Settings.UNSPAWNABLES (this last one is because i have a gamemode choice) but that is easy to fix you just need to use the same code that is on the settings class for the EARNED_ITEMS.
    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. REQUEST - 718 Matrix Developer
    By 03swatts3139 in forum Requests
    Replies: 0
    Last Post: 03-25-2014, 08:14 PM
  2. 718 [MATRIX] demote all command?
    By SpawnInsanity in forum Help
    Replies: 2
    Last Post: 05-04-2013, 05:43 AM
  3. [Request] [Paying] [718 matrix]
    By Icantcode911 in forum Buying
    Replies: 3
    Last Post: 12-07-2012, 04:20 PM
  4. Webdev Request [718 Matrix]
    By Genetic in forum Requests
    Replies: 0
    Last Post: 11-25-2012, 12:15 AM
  5. [718/Matrix]Itemdb.biz Search Command[718/Matrix]
    By benjamin94 in forum Snippets
    Replies: 12
    Last Post: 08-11-2012, 12:10 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
  •