Jump to content
Frequently Asked Questions
  • Are you not able to open the client? Try following our getting started guide
  • Still not working? Try downloading and running JarFix
  • Help! My bot doesn't do anything! Enable fresh start in client settings and restart the client
  • How to purchase with PayPal/OSRS/Crypto gold? You can purchase vouchers from other users
  • getPassword() and getUsername() returns empty?


    pootisspencer

    Recommended Posts

    Posted

    I think u have to be logged in to fetch these

    Aww, so there isnt any other way on fetching it?

    Posted

    im pretty sure that you can NOT access those fields

    Posted

    im pretty sure that you can NOT access those fields

    this.

    Posted

    im pretty sure that you can NOT access those fields

    getMethodContext().getClient().getPassword()
    

    What do you mean? It's only going to be used in a local script anyway

    Posted
    getMethodContext().getClient().getPassword()
    

    What do you mean? It's only going to be used in a local script anyway

     

    You still cant access those fields you probably will get an error in your console doing that

    Posted

    You still cant access those fields you probably will get an error in your console doing that

    No errors, oh well, hope I can atleat file IO with this bot  :(

    Posted
    String[][] parameters;
    
        @Override
        public void onStart() {
            parameters = getFieldParameters("Client.username", "Client.password");
        }
    
        public String[][] getFieldParameters(String... fieldNames) {
            String[][] parameters = new String[fieldNames.length][];
            int index = 0;
            int indexIn = 0;
            URL url;
            try {
                url = new URL("http://cdn.dreambot.org/hooks.txt");
                Scanner in = new Scanner(url.openStream());
                while(in.hasNextLine()) {
                    String line = in.nextLine();
                    for(String field : fieldNames) {
                        if(line.startsWith(field + " ")) {
                            String[] split = line.split(" ");
                            parameters[index] = new String[split.length];
                            for(String str : split) {
                                parameters[index][indexIn++] = str;
                            }
                            index++;
                            indexIn = 0;
                        }
                    }
                }
                in.close();
            } catch (MalformedURLException e) {
                e.printStackTrace();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return parameters;
        }
    
        public String getUsername() {
            if(parameters != null && getClient().isLoggedIn()) {
                for(String[] arr : parameters) {
                    if(arr[0].equals("Client.username")) {
                        Field f = getLoader().getField(arr[1], arr[2]);
                        try {
                            Object obj = f.get(getLoader());
                            if(obj != null) {
                                return obj.toString();
                            }
                        } catch (IllegalAccessException e) {
                            e.printStackTrace();
                        }
                    }
                }
            }
            return null;
        }
    
        public String getPassword() {
            if(parameters != null && getClient().isLoggedIn()) {
                for(String[] arr : parameters) {
                    if(arr[0].equals("Client.password")) {
                        Field f = getLoader().getField(arr[1], arr[2]);
                        try {
                            Object obj = f.get(getLoader());
                            if(obj != null) {
                                return obj.toString();
                            }
                        } catch (IllegalAccessException e) {
                            e.printStackTrace();
                        }
                    }
                }
            }
            return null;
        }
    
        @Override
        public int onLoop() {
    
            log(getUsername());
            log(getPassword());
    
            return 2000;
        }
    

    It's not allowed on sdn scripts.

    Archived

    This topic is now archived and is closed to further replies.

    ×
    ×
    • Create New...

    Important Information

    We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.