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
  • Try asking for help in the chatbox
  • getPassword() and getUsername() returns empty?


    pootisspencer
     Share

    Recommended Posts

    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

    Link to comment
    Share on other sites

    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

    Link to comment
    Share on other sites

    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.

    Edited by Soldtodie
    Link to comment
    Share on other sites

    Create an account or sign in to comment

    You need to be a member in order to leave a comment

    Create an account

    Sign up for a new account in our community. It's easy!

    Register a new account

    Sign in

    Already have an account? Sign in here.

    Sign In Now
     Share

    ×
    ×
    • 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.