Beenrange Posted June 28, 2018 Share Posted June 28, 2018 (edited) 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 June 28, 2018 by Beenrange Quote Link to comment Share on other sites More sharing options...
FrostBug Posted June 28, 2018 Share Posted June 28, 2018 (edited) 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 June 28, 2018 by FrostBug Quote Link to comment Share on other sites More sharing options...
Beenrange Posted June 28, 2018 Author Share Posted June 28, 2018 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. Quote Link to comment Share on other sites More sharing options...
FrostBug Posted June 28, 2018 Share Posted June 28, 2018 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 you can use the Tabs api to switch tabs 1 Quote Link to comment Share on other sites More sharing options...
Beenrange Posted June 28, 2018 Author Share Posted June 28, 2018 (edited) 17 minutes ago, FrostBug said: That is not the full error, but we'll work with it you can use the Tabs api to switch tabs Thanks for your help Edited June 28, 2018 by Beenrange Quote Link to comment Share on other sites More sharing options...