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

Sell OSRS Gold
Sign in to follow this  
Sidesteppin12

[SNIPPET] Jaywalker's Banking & GE API

Recommended Posts

Posted (edited)

I decided to create my own banking API that mimics tribots way of implementing the API as much as possible. Basically it would only contain nothing more than just method calls. Simple and easy to use.

This API is a reworked version that is currently in my jHerblore script. I intend to release my GE api as well once I have finished that one up too. The API requires DaxWalker & Wastedbro's Item Price API. Other than that the rest is achieveable with standard dependencies that already comes with tribot.

All of the method names are the same as the ones from Banking & GrandExchange class in tribot, with a few exceptions, the only difference is that these methods are called with different class names such as Banker & Exchanger, so they do not collide with the Banking & GrandExchange class of tribot and cause an ambiguity problem.

 

List of available methods:

Spoiler

Banker.openBankBooth()

Banker.openBankBanker()

Banker.openBank()

Banker.openTab()

Banker.close()

Banker.isInBank() - Should only be used after DaxWalking or other types of walking, otherwise use the standard tribot version.

Banker.isBankLoaded()

 

Banker.depositEquipment()

Banker.depositAllExcept(List<Integer> ids)

Banker.depositAllExcept(List<Integer> ids, boolean depositNoted)

Banker.depositAll()

Banker.deposit(int amount, int id)

Banker.deposit(int amount, String name)

 

Banker.withdraw(int amount, int id)

Banker.withdraw(int amount, int id, boolean stackException)

Banker.withdraw(int amount, String name)

Banker.withdraw(int amount, String name, boolean stackException)

Banker.withdrawNoted(int amount, int id)

Banker.withdrawNoted(int amount, int id, boolean stackException)

Banker.withdrawNoted(int amount, String name)

Banker.withdrawNoted(int amount, String name, boolean stackException)

 

Banker.withdrawByIds(int amount, List<Integer> ids)

Banker.withdrawByIds(int amount, List<Integer> ids, boolean stackException)

Banker.withdrawByIds_Noted(int amount, List<Integer> ids)

Banker.withdrawByIds_Noted(int amount, List<Integer> ids, boolean stackException)

Banker.withdrawByNames(int amount, List<String> names)

Banker.withdrawByNames(int amount, List<String> names, boolean stackException)

Banker.withdrawByNames_Noted(int amount, List<String> names)

Banker.withdrawByNames_Noted(int amount, List<String> names, boolean stackException)

 

Banker.walktToBank()

Banker.walkToBank(WalkingCondition condition)

Banker.walkToBank(RunescapeBank bank)

Banker.walkToBank(Runescape bank, WalkingCondition condition)

 

Walker.walkTo(Positionable positionable)

Walker.walkTo(Positionable positionable, WalkingCondition condition)

 

Exchanger.withdrawGP(int amount)

Exchanger.open()

Exchanger.close()

 

Exchanger.buy(List<Integer> ids, int amount, float multiplier)

Exchanger.buy(int id, int price, int amount, float multiplier)

Exchanger.buy(int id, int price, int amount)

Exchanger.sell(int id, int price, int amount, float multiplier)

Exchanger.sell(int id, int price, int amount)

 

Exchanger.collectBuy(int id, int amount, int timeToWait)

Exchanger.collectBuy(int id, int amount, int timeToWait, boolean trackProfit)

Exchanger.collectSell(int id, int amount, int timeToWait)

Exchanger.collectSell(int id, int amount, int timeToWait, boolean trackProfit)

 

Exchanger.clickOffer(int id, int amount, TYPE type)

Exchanger.getCompleted(int timeToWait)

Exchanger.clickSearchTarget(String item)

 

Some of the features this API offers:

- Methods that incorporate any form of withdrawing or depositing do not need you to first check if the bank is open nor if it is loaded. It will attempt to open the bank if it is not open before returning false, and wait for bank to load if it is not loaded yet.

- Methods that incorporate any form of buying or selling do not need you to first check if the exchange window is open. It will attempt to open the exchange window if it is not open before returning false.

- Deselector. All methods that require the mouse to click somewhere on the screen first check if an item or spell is selected, if it is then it will deselect whatever is selected before attempting the requested action.

- Additional failsafes, not just the deselector. Tribots banking api does not know if what you were trying to click actually was succesfully clicked. Instead it views succesfully calling the click function as a succesfull attempt. It's kind of like playing pin the nail to the donkey game. It does not know if it pinned it at the right location, but as long as it pinned it the function returns true. This is not true for all methods, some methods do actually check if the action was succesfully performed, however they do not reattempt the action if it failed. 1 call = 1 attempt. My api will reattempt any action that might fail, several times, before returning false and will also wait until inventory count is updated. For example using the tribot banking API if you were to deposit all your items and then immediately check your available inventory space before withdrawing items then it might not work as you wish because Banker.depositAll() returns before the action of depositing has finished.

- When banking, closes GrandExchange window if it is open.

- When buying/selling, closes the bank screen if it is open.

- Support for withdrawing items in noted format and with or without stack exception. Stack exception is basically if you wish to draw X amount of items in your inventory but you only had Y left, then you can choose if you wish to draw these items or not. Also supports depositing of noted item ids if you happen to pass a list with of items that contains items of unnoted item ids, but the item in your inventory is a noted version of the item in your inventory. Also will not deposit equipment or items if you have none equipped or in your inventory. There is a total of 4 different depositing methods and 16 different withdrawing methods.

- Unique dynamic sleeping method, all methods that should sleep already have sleeps implemented so you do not need to call a sleep after executing any of the methods. Involves random varying sleeps but will occasionally, every so often, in a irregular pattern, sleep a bit longer. I use this because I prefer it over General.sleep(). Feel free to replace it with whichever method you wish. Remember before running the main loop in your script to call:

jGeneral.get().generateSeed();

This will create a random number between 0-100 that will be added to your dynamic sleeps in milliseconds. This is so no bot has the same average reaction/sleeping time.

- When buying items on the GE, if the bot does not have any money or too little money in the inventory, it will check if you have enough of the missing amount in the bank and withdraw that amount.

- Custom buying method that checks for an exact string match of the item you wish to buy and chooses that one from the returned items in the buy window search box. The standard GE api does not do this and will for instance click the wrong herb when it searches for "Guam leaf" in the grand exhcange, this is because more than one item contains "guam leaf" in their name. Such as Grimy guam leaf and so on.

- Profit tracking when buying/selling items on the GE. This is optional.

 

GET THE SOURCE HERE!

 

UPDATES:

- Pushed new updates that fix some of the methods that I've tested a bit for now, bit of logic and efficiency improvements. Also added 2 new depositing methods. Remember to replace the old java files with the new ones.

- Pushed even more updates. Fixed interface problem for withdrawing noted items. My GE api is now also been released to the public. Enjoy! :)

Edited by Sidesteppin12

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

  • Similar Content

    • By daxmagex
      Click the spoiler for more progress reports!
       
       
       
      Posting a BUG REPORT
      Please read this and submit the report here.
      You can buy Credits with RSGP instantly here!
    • By ScriptsForMains
      https://tribot.org/repository/script/id/3461
      Start the script in the area you want to gather resources. Follow the prompts in the pop-up boxes and type exactly what's needed (pay attention to caps!!).  Uses ABC2 timing and custom antiban.  Lots of safety features (will log out if unsuccessful at banking, if experience hasn't been gained, if it can't click on its target, etc etc).  

      Supports mining, woodcutting, fishing, thieving (with coin pouches!!), and some hunter animals (can't remember which ones, it's been forever since I've used it for hunter :P).  I recommend using low ABC2 reductions for slower things (fishing or high level resources) and higher ABC2 reductions for stuff like power mining.  For slower things, this will make you move the mouse a lot less when waiting for your character to stop doing something and is much more realistic.  For faster things, you'll be standing around a lot less and getting more exp.  

      Uses Daxwalker to bank...  Right now I'm just using public keys so if it's not working it's likely because Daxwalker is busy.  
      It can also power level.  Just tell it what to drop!!

      Used this to get my stats up to Drag slayer 2 requirements...  Simple program but very effective.  

       


      Troubleshooting:
      If you run into any problems with the default file, delete it (it's in the AppData -> Roaming -> .tribot folder) 
    • By fl0shizzle
      Hey guys.
      Trying to accept an incoming trade but whenever I try to get the chatBox interface it's always null? It's definitely visible on the screen?
      My code is simply (where CHAT_PARENT is 137):
       
      When I use the following code to see if the interface is there, its not shown:
      Any ideas?
       
       
    • By NeuroGenix
      Post rewritten after rewritting and updating the code multiple times.
      So I decided to give writing my own GE API a go and this is what I've come up with so far, using Exchange#offer(name, price, quantity, buy) will do the following:
      If the GE is closed, it will open it and continue making the offer. If the price is set to -1 then it will use the buttons to increase or decrease the price, depending on whether it is a buy or sell offer, until it is at a price that will buy/sell instantly. Otherwise it will use the custom input button to set the price. It will set the quantity using the 1/10/100/1000 buttons. I plan on updating this to randomise between using them and the custom input method shortly. Edit* I hadn't even remembered implementing this until I saw it do it whilst testing the method, and it was beautiful, but if it goes over the buy quantity accidently, in the example I saw it was clicking +100 and clicked it again too fast so instead of stopping before its target of 875 it got to 900, it will then use the custom amount interface to input 875, beautiful. It will prioritise buy offers over sell offers so that if there isn't an empty slot available, or any items to collect, then it will cancel a sell offer, collect it and continue now it has a free slot. If there isn't a free slot available and we are trying to sell something it will return true, this is so that in my scripts it will remove the item from a toSell HashMap and put it back into the bank to sell later because it has bought the items it needs to continue botting. If it is instead trying to buy something and there are no empty slots or sell offers to cancel then it will wait for something to buy and continue once it can collect something and therefore has an empty slot. Update* It will now search for the item 1-3 words at a time checking the first 9 results each time and will choose the item as soon as it is visible as a human would. I might update this so that it randomises more, sometimes entering the whole first word of an items name straight away, because I sometimes do that, most of the time though I enter as few characters as I need to, I think, thoughts? Let me know what you think, the code is probably disgusting to look at for some of you but for others just starting out like me it could be a valuable learning tool, for how not to code All feedback and constructive criticism appreciated.
      Exchange Class
      GEInterfaces Class
      GEConditions Class
      InfoHelper Class
      Thank you to everyone that has read this far, it is appreciated
      Rewritten, if you have read again, even more appreciation!
    • By drunksigma
      I get nothing as output even though my bank  is open.
      @Override public void run() { while(true) { sleep(200); RSItem itemarray[] = Banking.getAll(); for(RSItem index : itemarray) { General.println(index.name + " ID: " + index.getID() + " Stack: " + index.getStack()); } }  
    • By Flamo353
      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"); } } }  
    • By erickho123
      BUY IT NOW!
      Monthly (Unlimited accounts) $10 https://tribot.org/repository/script/id/347
      RSGP: https://quickrsgp.com/buytribotcredits, (The system is fully automated.)

      I NO LONGER USE SKYPE. CONTACT ME ON DISCORD (Erick Ho#3027)
      You can also pm me on TRiBot, both will be treated with priority.
      ExShopper (previously known as ExBuyer), is a script that buys or sell items from most stores on Runescape. It has been rewritten to be more: efficient, noob-friendly, features, and open the script to a variety of things. It has been used by many members on TRiBot and have gotten over 5+ days of runtime in one go.
      It has the ability to accurately sell items (including karjama shop) and buy items. Please take the time to read the spoilers below for a more detailed description of what the script is capable of.
       
      Antiban [ABCL 10]
       
       
    • By AliveInMe
      Many beginners fail to understand how to navigate API's. Today I am going to show you how to navigate and understand TRiBots documentation.
      I. Open TRiBots API by following this link: https://tribot.org/doc/
      Your main screen should look like so:

      Don't be alarmed it's actually pretty easy to follow! I will begin by discussing the three main sections of our current screen.
      II. 3 Section main API page
      a) The API Packages: 

      Here is where you can find select classes per package and then broaden your search for a specific class in that package.
      *Helpful for import finding!*
      For the next screenshot, I clicked on org.tribot.api .
       
      b ) Here is where we can search a specific class available from all of the combined packages the API documents has to offer.

      Selecting a class will introduce the methods and descriptions associated with them.
      c) Finally, Here is the overview panel where we can use the navigation bar to our liking and also see class documentation! 

      You can search the Class Hierarchy, Deprecated Methods, Index, and Help section!
      Importance of the Index section
      The Index contains an alphabetic list of all classes, interfaces, constructors, methods, and fields. Which is helpful for searching a specific method in the API documentation!
      For this GIF example, I select the Index section and followed the alphabetical list to search for the getHealthPercent() method.
      https://i.imgur.com/JxnRL5p.gif
      III. Part A: Class Documentation

      For the following information, I will select the class RSNPC   from the classes section shown in  II. b .
      Your overview panel should now show the RSNPC class documentation as follows

       
      This is the classes name and associated package.
       
      This is the classes implemented interfaces *If applicable*.
      Implementing the methods that allow us to get the RSNPC#RSTile, and RSNPC#Click methods.
       
      This shows the classes that it extends 
      Allowing us to use the methods associated with RSCharacter .  Some classes also show the description of the class as shown here .
       
      II. Part B: Class documentation Method Summary
      Scrolling down will show us the Method Summary .

       
      This section shows us the Method & Description and the return types each method returns.
      1st column = data type of the method
      2nd column = Method and Description of that method
       
      Clicking on any of those methods it will bring you down to a more in-depth explanation of the method.
      For this picture example I chose RSNPC#getDefinition()

      Marked in RED is the Name
      Marked in GREEN is the  DataType, Method Name, and Possible parameters a method could have
      Marked in BLUE is the description of the method.
      Marked in YELLOW is the return type of the method.
       
       
      I hope my tutorial helped some of you. If a topic needs a better explanation, please feel free to address it to me in the comment section.
      Thank you,
      AliveInMe
    • By Endvr
      Hi,
      Does anyone have an API for the Grand Exchange they don't mind sharing with me, or giving me a few pointers on creating one myself, as the current TRiBot API seems to be having some issues with Interface IDs
    • By yutpod
      What is the correct way for checking if item exists in the bank?
      This fails around 1 out of 500 times.
      I'm stomped on why it fails, bank screen is open and item is visible within the screen, when this condition returns true.
      if (Banking.isBankScreenOpen() && Banking.find("name").length == 0) { // Stop script, etc } Thanks.
       
      Edit: Full code of my Banking task if it is due to something else I'm missing.
      package scripts.api.tasks; import org.tribot.api2007.Banking; import org.tribot.api2007.Inventory; import org.tribot.api2007.types.RSArea; import scripts.api.BuildConfig; import scripts.api.ScriptController; import scripts.api.helpers.Timing07; import scripts.api.util.Log; import scripts.api.antiban.Reaction07; import scripts.api.frameworks.task.Task; import scripts.api.helpers.Inventory07; import scripts.api.helpers.Player07; import scripts.api.tasks.models.BankItem; import java.util.List; public class Bank implements Task { private static final String TAG = Bank.class.getName(); private int priority; private List<BankItem> items; private RSArea bankArea; private String[] names; public Bank(int priority, List<BankItem> items, RSArea bankArea) { this.priority = priority; this.items = items; this.bankArea = bankArea; this.names = items.stream().map(BankItem::getName).toArray(String[]::new); } @Override public int priority() { return priority; } @Override public boolean validate() { return Player07.isInArea(bankArea) && !Inventory07.contains( items.stream() .filter(BankItem::isRequired) .map(BankItem::getName) .toArray(String[]::new) ); } @Override public void execute() { Log.v(TAG, "execute: Starting task"); if (!Banking.isBankScreenOpen()) { openBank(); } if (Banking.isBankScreenOpen()) { deposit(); withdraw(); } } private void openBank() { Log.d(TAG, "openBank: Opening bank"); if (!Player07.isAnimating() && Banking.openBankBooth()) { Timing07.waitCondition(Banking::isBankScreenOpen, Reaction07.getInstance().getNextClickTime()); } } private void deposit() { Log.d(TAG, "deposit: Depositing items"); if (!Inventory07.containsOnly(names)) { Log.w(TAG, "deposit: Miscellaneous items found in inventory!"); Banking.depositAllExcept(names); } } private void withdraw() { Log.d(TAG, "withdraw: Withdrawing items"); if (!Inventory07.contains(names)) { items.forEach(bankItem -> { if(!Inventory.isFull() && bankItem.isRequired()) { if (bankItem.getRequiredCount() == 0 || Inventory.getCount(bankItem.getName()) < bankItem.getRequiredCount()) { if(BuildConfig.DEBUG) { Log.d(TAG, "withdraw: Withdrawing item: " + bankItem.getName()); } if (Banking.withdraw(bankItem.getRequiredCount(), bankItem.getName())) { Timing07.waitCondition( () -> Inventory.getCount(bankItem.getName()) >= bankItem.getMinCount(), Reaction07.getInstance().getNextClickOptionTime() ); } else if (Banking.isBankScreenOpen() && Banking.find(bankItem.getName()).length == 0) { Log.c(TAG, "withdraw: Missing an item in a Bank: " + bankItem.getName()); ScriptController.getInstance().setRunning(false); } } } }); } } }  
  • Our picks

    • Over the past few months, I’ve been working diligently on a new project - TRiBot X. Everything has been written from the ground up, with all of the best practices of software engineering. Every aspect of TRiBot has been re-imagined to support three main goals: flexibility, useability, and reliability.
        • Like
      • 30 replies
    • Come give us feedback on the next version of TRiBot!
      • 74 replies
    • TRiBot is looking to improve a lot of its customer relationship management, customer on boarding process, customer experience, design elements, community engagement and pretty much everything else you can imagine when it comes to marketing.

      Our goal: To ensure that the marketing done TRULY reflects the experience and does not shine an inaccurate light on what TRiBot is lacking in.

      So I ask, what do you love about TRiBot and what do you hate about TRiBot? What does O S Bot, Rune M8, PowR Bot and Dre amBot do better? (yes I purposely didn't spell it right 😂).

      Love, 

      RileyZ
      • 23 replies
    • Over the last three weeks, I've been working on upgrading our server infrastructure. It's finally ready and is now live!

      Why?

      Increased reliability - less server errors


      Increased availability - less downtime


      Increased security - keeping us and you secure


      Increased capacity - ability to serve you better


      Increased speed - less waiting for things to load


      Faster development - server and service updates will come faster


      What are the changes?

      Move from a single AWS EC2 instance to AWS ECS (Elastic Container Service)


      Distributed computing


      Load balancing


      Git management of server files and filesystem


      Redis caching


      How?

      AWS ECS (with 10 EC2 instances)


      AWS ElastiCache (Redis)


      AWS Load Balancing


      AWS EFS (Elastic file system)


      Please bare with us as I continue to tune the server for maximum performance. Slow loading speeds may occur temporarily. I thank everyone for their patience.

      Please post on this thread if you experience any issues other than slow loading times.
      • 51 replies
    • This release will:

      Fix prayers and world hopper API (Thanks @JoeDezzy1 and @erickho123)


      Improve banking API (Thanks @Encoded)


      Adds methods for returning and using Java Lists, rather than arrays


      Slightly randomizes some hardcoded behaviour


      Removes sleeps from waitConditions; the efficiency saving potential is negligible in these use-cases, therefore cleaner code is preferable


      Other back-end improvements





      Note: If you are using LG, please restart both the RS client and TRiBot.
      • 90 replies
  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...