Jump 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.

chatWorld() - Find the world most of the people in clan chat are in.

Featured Replies

Could probably be done better but I don't think there is a built-in function to find it nor did I see any PC bots utilizing it. (Yes this was originally made for automatic world hopping in PC.)

 

 

The Code for mode() was found here: http://deveshsharma.info/2013/07/16/find-most-common-element-in-a-list-in-java/

^ because I didn't want to make it.

import java.awt.Graphics;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.osbot.script.Script;
import org.osbot.script.ScriptManifest;
import org.osbot.script.rs2.ui.RS2InterfaceChild;
import org.osbot.script.rs2.ui.Tab;

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 {
    openTab(Tab.CLANCHAT);
    List < Integer > chatWorlds = new ArrayList < Integer > ();
    int hopWorld = -1;
    RS2InterfaceChild chatbox = client.getInterface(589).getChild(5);
    RS2InterfaceChild[] people = chatbox.getChildren();
    for (RS2InterfaceChild world: people) {
        if (world.getMessage().contains("World ")) {
            chatWorlds.add(Integer.parseInt(world.getMessage().replace("World ", "")));
        }
    }
    hopWorld = mode(chatWorlds);
    return hopWorld;
}

Edited by Fay

  • Author

Lol, I'd believe it. But then again you didn't release it tongue.png (the source I mean).

Edited by Fay

  • 2 weeks later...

is this the correct way of using it

 

 public void hop() throws Exception{
       if(client.getCurrentWorld() != mostCommonKey){
       this.worldHopper.hopWorld(mostCommonKey);
       }
   }

 

 

please help

Edited by lazyy

Guest
This topic is now closed to further replies.

Recently Browsing 0

  • No registered users viewing this page.

Account

Navigation

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.