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.

having an issue where it types into chat what it should be typing into the box

Featured Replies


/**

* @(#)Smither.java

*

*

* @author Construct Dylons

* @version 1.00 2016/6/10

*/

import org.osbot.rs07.api.model.RS2Object;

import org.osbot.rs07.script.Script;

import org.osbot.rs07.script.ScriptManifest;

import org.osbot.rs07.api.map.Position;

import org.osbot.rs07.input.mouse.EntityDestination;

import org.osbot.rs07.input.mouse.MiniMapTileDestination;

import org.osbot.rs07.utility.Area;

import java.awt.*;

@ScriptManifest(author = "Construct Dylons", info = "Not So Basic Smither.", name = "Smither", version = 0, logo = "")

public class Smither extends Script{

private static final Area SMITHING_AREA = new Area(3185,3420,3190,3427);

private static final String useItem = "Iron bar";

private static final String itemMade = "Iron knife";

private static final int xCo = 370;

private static final int yCo = 180;

private enum State{

SMITH, BANK, WALK_TO_SMITH, WALK_TO_BANK

};

private State getState(){

if(inventory.contains(useItem) && SMITHING_AREA.contains(myPlayer().getPosition())){

return State.SMITH;

}

else if(!inventory.contains(useItem) && !SMITHING_AREA.contains(myPlayer().getPosition())){

return State.BANK;

}

else if(inventory.contains(useItem) && !SMITHING_AREA.contains(myPlayer().getPosition())){

return State.WALK_TO_SMITH;

}

else{

return State.WALK_TO_BANK;

}

}

public int onLoop() throws InterruptedException{

switch(getState()){

case SMITH:

outerIf:

if(!myPlayer().isAnimating()){

sleep(1000);

if(!inventory.contains(useItem)){

sleep(500);

break outerIf;

}

int failSafe = 0;

while(!myPlayer().isAnimating()){

sleep(50);

failSafe++;

if(failSafe >= 10){

inventory.interactWithNameThatContains("Use", useItem);

RS2Object anvil = objects.closest(2097);

mouse.click(new EntityDestination(bot, anvil));

if(interfaces.get(312) != null){

}

sleep(1500);

mouse.move(xCo,yCo);

mouse.click(true);

sleep(250);

mouse.move(365,250);

mouse.click(false);

sleep(1000);

keyboard.typeString("27");

sleep(500);

break outerIf;

}

}

}

break;

case BANK:

RS2Object bankBooth = objects.closest("Bank booth");

if (bankBooth != null) {

if (bankBooth.interact("Bank")) {

while(!bank.isOpen()){

sleep(250);

}

bank.depositAll(itemMade);

if(bank.contains(useItem)){

bank.withdraw(useItem, 27);

}

else{

stop();

}

bank.close();

}

}

break;

case WALK_TO_BANK:

walkTile(new Position(3185,3436,0));

break;

case WALK_TO_SMITH:

walkTile(new Position(3185,3426,0));

break;

}

return random(200,300);

}

private boolean walkTile(Position p) throws InterruptedException {

mouse.move(new MiniMapTileDestination(bot, p), false);

sleep(random(150, 250));

mouse.click(false);

int failsafe = 0;

while (failsafe < 10 && myPlayer().getPosition().distance(p) > 2) {

sleep(200);

failsafe++;

if (myPlayer().isMoving())

failsafe = 0;

}

if (failsafe == 10)

return false;

return true;

}

public void onPaint(Graphics2D g) {

}

}

Try looking at the ConditionalSleep class, which you should use until the dialogue box is open. A static 1000 ms sleep will not always guarantee that this opened, a simple lag will cause it not to appear within 1 tick (600-630 ms) which will result in typing in the chatbox.

 

You can also replace those mouse moves and clicks with a right click on a WidgetDestination and then select a menu option via the Menu class.

As he has stated above, use widget debugger to find a widget ID that pertains specifically to the box that you intend on the bot to type in. So that way if the widget is not visible or is null then it will not type until it is visible or !null.

 

For example:

if (widgets.get(162, 32) !=null && widgets.get(162, 32).isVisible()) {
      keyboard.typeString("28");
   }

Edited by Strange_Fk

Create an account or sign in to comment

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.