Skip to content
View in the app

A better way to browse. Learn more.

OSBot :: 2007 OSRS Botting

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Getting most common world in clan chat

Featured Replies

 

Based on this thread: https://osbot.org/forum/topic/44402-chatworld-find-the-world-most-of-the-people-in-clan-chat-are-in/

 

I have tried to implement something similar

    private static int mode(List <Integer> list) {

        Map < Integer, Integer > map = new HashMap < Integer, Integer > ();

        for (int i = 0; i < list.size(); i++) {

            Integer frequency = map.get(list.get(i));
            if (frequency == null) {
                map.put(list.get(i), 1);
            } else {
                map.put(list.get(i), frequency + 1);
            }
        }

        int mostCommonKey = -1;
        int maxValue = -1;
        for (Map.Entry < Integer, Integer > entry: map.entrySet()) {

            if (entry.getValue() > maxValue) {
                mostCommonKey = entry.getKey();
                maxValue = entry.getValue();
            }
        }

        return mostCommonKey;
    }

    public int chatWorld() throws InterruptedException {
        List < Integer > chatWorlds = new ArrayList <Integer> ();
        int hopWorld = -1;
        RS2Widget chatbox = widgets.get(589, 5);
        RS2Widget[] people = chatbox.getChildWidgets();
        for (RS2Widget world: people) {
            if (world.getMessage().contains("World ")) {
                chatWorlds.add(Integer.parseInt(world.getMessage().replace("World ", "")));
            }
        }
        hopWorld = mode(chatWorlds);
        return hopWorld;
    }

I get an error at the line:

       RS2Widget[] people = chatbox.getChildWidgets();

 

Where am I going wrong? Basically all I want to do is get the most common world in the clan chat that I'm currently in.

 

Thank you

Edited by Beenrange

17 minutes ago, Beenrange said:

I get an error at the line:

       RS2Widget[] people = chatbox.getChildWidgets();

Where am I going wrong? Basically all I want to do is get the most common world in the clan chat that I'm currently in.

Thank you

In the future, including the error may be helpful.

Probably the widget 'chatbox' is null in this case, though. In other words a widget with those IDs was not loaded or visible at the time.

Edited by FrostBug

  • Author
10 minutes ago, FrostBug said:

In the future, including the error may be helpful.

Probably the widget 'chatbox' is null in this case, though. In other words a widget with those IDs was not loaded or visible at the time.

Sorry - the error is as follows:

 

[INFO][Bot #1][06/28 02:07:27 PM]: scripts.ArdyKnightsHailzy.chatWorld(ArdyKnightsHailzy.java:206)
[INFO][Bot #1][06/28 02:07:27 PM]: scripts.ArdyKnightsHailzy.hop(ArdyKnightsHailzy.java:218)
[INFO][Bot #1][06/28 02:07:27 PM]: scripts.ArdyKnightsHailzy.thieve(ArdyKnightsHailzy.java:110)
[INFO][Bot #1][06/28 02:07:27 PM]: scripts.ArdyKnightsHailzy.onLoop(ArdyKnightsHailzy.java:55)
[INFO][Bot #1][06/28 02:07:27 PM]: org.osbot.rs07.event.ScriptExecutor$InternalExecutor.run(kl:223)
[INFO][Bot #1][06/28 02:07:27 PM]: java.lang.Thread.run(Unknown Source)

 

I found it largely unhelpful so thats why I didn't include it. Essentially what I'm trying to do is this:

 

//get the chatbox containing the list of all users in clan and their worlds 
RS2Widget chatbox = widgets.get(589, 5);
//get an array of people in the clan chat including their world
 RS2Widget[] people = chatbox.getChildWidgets();

 

I can't see why it doesn't work, as to my knowledge them ID's are correct. My only thought atm is that I need to move into the clan 'tab' before I call them lines, but I'm unsure of how to do that atm. 

1 minute ago, Beenrange said:

Sorry - the error is as follows:

 

[INFO][Bot #1][06/28 02:07:27 PM]: scripts.ArdyKnightsHailzy.chatWorld(ArdyKnightsHailzy.java:206)
[INFO][Bot #1][06/28 02:07:27 PM]: scripts.ArdyKnightsHailzy.hop(ArdyKnightsHailzy.java:218)
[INFO][Bot #1][06/28 02:07:27 PM]: scripts.ArdyKnightsHailzy.thieve(ArdyKnightsHailzy.java:110)
[INFO][Bot #1][06/28 02:07:27 PM]: scripts.ArdyKnightsHailzy.onLoop(ArdyKnightsHailzy.java:55)
[INFO][Bot #1][06/28 02:07:27 PM]: org.osbot.rs07.event.ScriptExecutor$InternalExecutor.run(kl:223)
[INFO][Bot #1][06/28 02:07:27 PM]: java.lang.Thread.run(Unknown Source)

 

I found it largely unhelpful so thats why I didn't include it. Essentially what I'm trying to do is this:

 


//get the chatbox containing the list of all users in clan and their worlds 
RS2Widget chatbox = widgets.get(589, 5);
//get an array of people in the clan chat including their world
 RS2Widget[] people = chatbox.getChildWidgets();

 

I can't see why it doesn't work, as to my knowledge them ID's are correct. My only thought atm is that I need to move into the clan 'tab' before I call them lines, but I'm unsure of how to do that atm. 

That is not the full error, but we'll work with it :xboge:
you can use the Tabs api to switch tabs

  • Author
17 minutes ago, FrostBug said:

That is not the full error, but we'll work with it :xboge:
you can use the Tabs api to switch tabs

Thanks for your help :)

Edited by Beenrange

Create an account or sign in to comment

Recently Browsing 0

  • No registered users viewing this page.

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.