Jump to content
Search In
  • More options...
Find results that contain...
Find results in...
Buy OSRS Gold

Sell OSRS Gold

Search the Community

Showing results for tags 'tribot shop api'.



More search options

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • TRiBot
    • News and Announcements
    • Old School Scripts
    • Help and Guidance
    • Development
    • Bugs and Errors
    • Tutorials
  • Scripters' Forums
    • Scripter Application
  • RuneScape®
    • General
    • Guides/Tutorials
    • Achievements
  • General
    • General
    • Questions
    • Discussions & Debates
    • Introductions
    • Suggestions
    • Feedback
  • The Black Market
    • Disputes
    • Repository Credits
    • Gold Exchange
    • Item Exchange
    • Membership Sales
    • Services
    • Other
    • Middleman Services

Blogs

  • Getting Started With TRiBot
  • The Best Way To Get Rid Of Termites
  • How to Generate Real Estate Leads Using Twitter
  • A Guide to Landing Pages
  • Dog Grooming in Sydney – 5 steps to finding a grooming salon
  • Cheap RS 2007 Gold for Spring 2020!
  • Logo Design Mistakes- Your Business Should Avoid at All Cost
  • Effective Pest Control Measures
  • В Алматы карантин из-за коронавируса: жизнь в условиях пандемии
  • Preschool Educational Toys, Helping One's Child Prepare For the Future
  • Automating Tribot
  • Payment error
  • Animal Crossing: New Horizons Cuts Player Interest Rates
  • network-security-engineer
  • SERVICES 100% BY HAND

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


Location


Bio

Found 1 result

  1. Description: I thought some new scripters might find this useful. So I rewrote @TehRhio's old shop api since it's #getAll method was outdated. Original Thread: Snippet: import org.tribot.api.Timing; import org.tribot.api.types.generic.Condition; import org.tribot.api2007.Interfaces; import org.tribot.api2007.Inventory; import org.tribot.api2007.types.RSInterfaceChild; import org.tribot.api2007.types.RSInterfaceComponent; import org.tribot.api2007.types.RSItem; import org.tribot.api2007.types.RSItemDefinition; import java.awt.*; import java.util.ArrayList; import java.util.Arrays; public class OSShopping { private static final int MASTER_ID = 300; private static final int FRAME_CHILD_ID = 1; private static final int ITEMS_CHILD_ID = 2; public static boolean isShopOpen() { return Interfaces.get(MASTER_ID, ITEMS_CHILD_ID) != null; } public static String getShopName() { RSInterfaceChild frame = Interfaces.get(MASTER_ID, FRAME_CHILD_ID); if (frame != null) { return frame.getText(); } return ""; } public static boolean close() { RSInterfaceChild frame = Interfaces.get(MASTER_ID, FRAME_CHILD_ID); if (frame != null) { RSInterfaceComponent closeButton = frame.getChild(11); return closeButton != null && closeButton.click("Close") && Timing.waitCondition(new Condition() { @Override public boolean active() { return !isShopOpen(); } }, 2000); } return false; } public static RSItem[] getAll() { ArrayList<RSItem> itemList = new ArrayList<>(); RSInterfaceChild itemsChild = Interfaces.get(MASTER_ID, ITEMS_CHILD_ID); if (itemsChild != null && itemsChild.getChildren() != null) { for (int i = 0; i < itemsChild.getChildren().length; i++) { RSInterfaceComponent itemComponent = itemsChild.getChild(i); if (itemComponent != null && !itemComponent.isHidden()) { final int garbageLength = 11; String name = itemComponent.getComponentName(); Rectangle bounds = itemComponent.getAbsoluteBounds(); if (name != null && name.length() >= garbageLength && bounds != null) { RSItem item = new RSItem(name.substring(garbageLength).replace("</col", ""), itemComponent.getActions(), itemComponent.getIndex(), itemComponent.getComponentItem(), itemComponent.getComponentStack(), RSItem.TYPE.OTHER); item.setArea(bounds); itemList.add(item); } } } } return itemList.toArray(new RSItem[itemList.size()]); } public static boolean contains(String... names) { return get(names).length > 0; } public static boolean contains(int... ids) { return get(ids).length > 0; } public static RSItem[] get(String... names) { ArrayList<RSItem> items = new ArrayList<>(); for (RSItem i : getAll()) { RSItemDefinition definition = i.getDefinition(); if(definition != null && Arrays.asList(names).contains(definition.getName())) { items.add(i); } } return items.toArray(new RSItem[items.size()]); } public static RSItem[] get(int... ids) { ArrayList<RSItem> items = new ArrayList<>(); for (RSItem i : getAll()) { if(Arrays.asList(ids).contains(i.getID())) { items.add(i); } } return items.toArray(new RSItem[items.size()]); } public static int getCount(String... name) { int total = 0; for (RSItem item : get(name)) { total += item.getStack(); } return total; } public static int getCount(int... id) { int total = 0; for (RSItem item : get(id)) { total += item.getStack(); } return total; } public static boolean buy(int amount, String name) { RSItem[] items = get(name); RSItem item = items.length > 0 ? items[0] : null; return item != null && item.getStack() > 0 && exchangeItem(amount, "Buy", item); } public static boolean buy(int amount, int id) { RSItem[] items = get(id); RSItem item = items.length > 0 ? items[0] : null; return item != null && item.getStack() > 0 && exchangeItem(amount, "Buy", item); } public static boolean sell(int count, String name) { RSItem[] items = Inventory.find(name); return items.length > 0 && exchangeItem(count, "Sell", items[0]); } public static boolean sell(int count, int id) { RSItem[] items = Inventory.find(id); return items.length > 0 && exchangeItem(count, "Sell", items[0]); } private static boolean exchangeItem(int amount, String action, RSItem item) { if (amount >= 50 && action.equals("Sell")) { return item.click(action + " 50"); } else if (amount >= 10) { return item.click(action + " 10"); } else if(amount >= 5) { return item.click(action + " 5"); } else { return item.click(action + " 1"); } } }
×
×
  • Create New...