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.

Easy Trade Method

Featured Replies

	protected abstract static class Widgets {

		public static boolean containsText(int parent, int child, String text) {
			RS2Widget widget = s.getWidgets().get(parent, child);
			if (exists(widget) && widget.isVisible()) {
				return widget.getMessage().contains(text);
			}
			return false;
		}

		public static boolean interactTil(String action, int i, int j, int k, ConditionalSleep con) {
			RS2Widget widget = s.getWidgets().get(i, j, k);
			if (exists(widget)) {
				widget.interact(action);
				con.sleep();
				return true;
			}
			return false;
		}

		public static String getText(int i, int j) {
			RS2Widget widget = s.getWidgets().get(i, j);
			if (exists(widget) && widget.isVisible()) {
				return widget.getMessage();
			}
			return "";
		}

		private static boolean exists(RS2Widget widget) {
			return widget != null;
		}


		public static boolean interactTil(String action, int parent, int child, ConditionalSleep con) {
			RS2Widget widget = s.getWidgets().get(parent, child);
			if (exists(widget)) {
				widget.interact(action);
				con.sleep();
				return true;
			}
			return false;
		}

		public static boolean interactTilNull(String action, int parent, int child) {
			RS2Widget widget = s.getWidgets().get(parent, child);
			if (exists(widget)) {
				widget.interact(action);
				new ConditionalSleep(2500, 3000) {
					@Override
					public boolean condition() {
						return !exists(widget);
					}
				}.sleep();
				return true;
			}
			return false;
		}

		public static boolean interactTilNull(String action, int parent, int child, int child2) {
			RS2Widget widget = s.getWidgets().get(parent, child, child2);
			if (exists(widget)) {
				widget.interact(action);
				new ConditionalSleep(2500, 3000) {
					@Override
					public boolean condition() {
						return !exists(widget);
					}
				}.sleep();
				return true;
			}
		return false;
		}

	}
protected abstract static class Trade {

		public static boolean isTrading() {
			return s.getTrade().isCurrentlyTrading() || s.getTrade().isFirstInterfaceOpen() || s.getTrade().isSecondInterfaceOpen();
		}

		public static void trade(String name, HashMap<String, Integer> itemSet, boolean acceptLast) {
			String cleanName = name.replaceAll(" ", "\\u00a0");
			Player player = s.getScript().getPlayers().closest(cleanName);
			if (player != null && !isTrading() && player.interact("trade with")) {
				new ConditionalSleep(3000, 4000) {
					@Override
					public boolean condition() {
						return isTrading();
					}
				}.sleep();
			}

			if (isTrading() && s.getTrade().isFirstInterfaceOpen()) {
				if (!tradeOfferMatches(itemSet)) {
					for (String item : itemSet.keySet()) {
						if (!s.getTrade().getOurOffers().contains(item)) {
							if (s.getTrade().offer(item, itemSet.get(item))) {
								new ConditionalSleep(2000, 3000) {

									@Override
									public boolean condition() {
										return s.getTrade().getOurOffers().contains(item);
									}
								}.sleep();
							}
						}
					}
				} else {
					if (acceptLast && s.getTrade().didOtherAcceptTrade()) {
						if (Widgets.interactTil("Accept", 335, 11, new ConditionalSleep(1500, 2000) {
							@Override
							public boolean condition() {
								return s.getTrade().isSecondInterfaceOpen();
							}
						})) {
							new ConditionalSleep(3000, 4000) {
								@Override
								public boolean condition() {
									return s.getTrade().isSecondInterfaceOpen();
								}
							}.sleep();
						}

					} else if (!acceptLast && !hasAccepted()) {
						if (Widgets.interactTil("Accept", 335, 11, new ConditionalSleep(1500, 2000) {
							@Override
							public boolean condition() {
								return hasAccepted();
							}
						})) {
							new ConditionalSleep(3000, 4000) {

								@Override
								public boolean condition() {
									return s.getTrade().isSecondInterfaceOpen();
								}
							}.sleep();
						}
					}

				}
			} else if (isTrading() && s.getTrade().isSecondInterfaceOpen()) {
				
					if (acceptLast && s.getTrade().didOtherAcceptTrade()) {
						if (Widgets.interactTil("Accept", 334, 25, new ConditionalSleep(1500, 2000) {
							@Override
							public boolean condition() {
								return !isTrading();
							}
						})) {
							new ConditionalSleep(3000, 4000) {

								@Override
								public boolean condition() {
									return s.getTrade().isSecondInterfaceOpen();
								}
							}.sleep();
						}

					} else if (!acceptLast && !hasAccepted()) {
						if (Widgets.interactTil("Accept", 334, 25, new ConditionalSleep(1500, 2000) {
							@Override
							public boolean condition() {
								return !isTrading();
							}
						})) {
							new ConditionalSleep(3000, 4000) {
								@Override
								public boolean condition() {
									return s.getTrade().isSecondInterfaceOpen();
								}
							}.sleep();
						}

					}
			}
		}

		private static boolean hasAccepted() {
			return Widgets.containsText(335, 30, "Waiting for other player...") || Widgets.containsText(334, 4, "Waiting for other player...");
		}

		private static boolean tradeOfferMatches(HashMap<String, Integer> itemSet) {
			for (String item : itemSet.keySet()) {
				if (isTrading() && s.getTrade().getOurOffers().getItem(item) == null) {
					s.log("Trade Offer Missing: " + item);
					return false;
				}
			}
			return true;
		}
	}

Note: you can make it non static / abstract just remove the s.* thats just how my api is.

 

Usage: 

HashMap<String, Integer> itemMap = new HashMap<String, Item>();
itemMap.put("Shark", 12);
itemMap.put("Coins", 42069);
private int onLoop(){
if(shouldTrade())
     trade("Zezima", itemMap, false); //trades zezima the itemMap and doesnt wait for them to accept.
return 250;
}

Edited by LoudPacks

  • Author
public static boolean interactTil(String action, int i, int j, int k ...

Parameter names feels.png

 

 

Just had 2 params before and auto added method lol 

  • 2 weeks later...

ummm, trying to learn java and just looked at this. Looks so fucking confusing.

  • 3 weeks later...

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.