Everything posted by BravoTaco
-
Tracking progress
First declare the variable coinChange as a private or public field depending on how you are using it. Than in your script before you go to pick up the coins you set a local temp variable as the current amount of coins in your inventory this will be the old amount. Than once you have picked up the coins you would than take the current amount of coins in the inventory and subtract that from the old amount. Than add that to the coinChange variable. I can write up a code example if you need 🙂
-
Tracking progress
To retrieve how much coins you have picked up you would first set a temp variable to hold the old coin amount and than once you have picked up the coins you would just simply subtract the current amount of coins in your inventory with the old amount. IE. 100 coins in inventory before picking up the coins on the ground. 200 coins after picking up coins. 200 - 100 = 100 coins were picked up. Or you could get the ground item amount than add that amount to your variable. You would still need to make sure you picked it up before adding that value though.
-
CLI launch help
To skip the Boot UI, you have to declare a login. EX. -login user:pass Here's a list of the CLI commands:
-
How to Multi-thread [Easy]
If you are wanting to use the Event class in the OSBot API than its rather easy to do. First declare an Event object. attackTarget(), would be a custom method that handles finding an NPC to attack, and than also attacking that target. private Event attackEvent = new Event() { @Override public int execute() throws InterruptedException { if (!myPlayer().isUnderAttack()) { attackTarget(); } return 0; } }; Than in you're onStart you can set the attackEvent to be an Async operation. attackEvent.setAsync(); When you want to execute the event you than call the execute() method and pass the Event object name into it. execute(attackEvent);
-
Script not displayed
You have to build out the project as .jar file into the scripts folder. What IDE are you using? If you are using IntelliJ than this may help: This for Eclipse:
-
Pulling GE price's
I wrote up a quick class to get item prices from the runescape's ge services. For some reason I don't have the spoiler button? Anyways here's the class. import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.net.URL; import java.net.URLConnection; import java.util.HashMap; public final class OsRsExchange { private final HashMap<Integer, Long> cachedItems = new HashMap<>(); private static OsRsExchange instance; private OsRsExchange() {} public static OsRsExchange getInstance() { if (instance == null) instance = new OsRsExchange(); return instance; } public void cacheItemPricesFromArray(int[] itemIdsArray) { for (int value : itemIdsArray) { cacheItemPrice(value); } } public boolean cacheItemPrice(int itemId) { String urlLink = "http://services.runescape.com/m=itemdb_oldschool//viewitem?obj=" + itemId; try { URL url = new URL(urlLink); URLConnection connection = url.openConnection(); InputStream inputStream = connection.getInputStream(); BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(inputStream)); String line; StringBuilder sb = new StringBuilder(); while ((line = bufferedReader.readLine()) != null) sb.append(line); int indexOfPrice = sb.indexOf("Current Guide Price"); String priceString = ""; try { priceString = sb.substring(indexOfPrice, sb.indexOf(">", indexOfPrice)); } catch (StringIndexOutOfBoundsException si) { si.printStackTrace(); System.out.println("Invalid Item Id!"); return false; } priceString = priceString.substring(priceString.indexOf("'") + 1, priceString.lastIndexOf("'")); String[] splitPriceString = priceString.split(","); sb = new StringBuilder(); for (String s : splitPriceString) { sb.append(s); } long priceOfItem = -1; try { priceOfItem = Long.parseLong(sb.toString()); } catch (NumberFormatException nfe) { nfe.printStackTrace(); System.out.println("Incorrect string format to be converted to a long!"); } if (cachedItems.containsKey(itemId)) cachedItems.replace(itemId, priceOfItem); else cachedItems.put(itemId, priceOfItem); return true; } catch (IOException e) { e.printStackTrace(); } return false; } public long getPriceOfItem(int itemId) { if (!cachedItems.containsKey(itemId)) { System.out.println("The cached items does not contain this Item Id!"); return -1; } return cachedItems.get(itemId); } public HashMap<Integer, Long> getCachedItems() { return cachedItems; } public void clearCachedItems() { cachedItems.clear(); } @Override public String toString() { StringBuilder sb = new StringBuilder(); if (cachedItems.size() > 0) cachedItems.forEach((id, price) -> sb.append(String.format("%s :: %s\n", id, price))); return sb.toString(); } } To use //Recommended to use an array in the onStart of your script as retrieving the prices is a pretty taxing process. int[] itemIds = new int[]{556, 892, 811, 1436, 2627, 5641}; OsRsExchange.getInstance().cacheItemPricesFromArray(itemIds); System.out.println(OsRsExchange.getInstance()); //If you want to do individual items OsRsExchange.getInstance().cacheItemPrice(3202); System.out.println(OsRsExchange.getInstance()); //Retrieve price of item by calling getPriceOfItem() long price = OsRsExchange.getInstance().getPriceOfItem(2627); System.out.println(price);
-
Scripting bug?
What item is it? How is the item being spawned into the game world? IE. NPC drop? Timer? Is it always in the same spot when you are trying to interact with it? When you say logging in/out fixes it sometimes, are you completely exiting the client for it to be fixed or are you just logging in/out? Mirror mode or Stealth? Are you able to interact with other ground items when you can't interact with this one?
-
Scripting bug?
What object is it? Also if your able to get the mouse to move over it than you can create a custom interaction for it until it gets fixed. IE force mouse to click after hovering. Or right click and than move the mouse to the needed action.
-
Pulling GE price's
Never used this, what does getExchangeItem() return?
-
Cannot resolve symbol "RS2Object" & Cannot resolve method "interact"
For objects you have to import org.osbot.rs07.api.model.RS2Object Also in intellij u can click the RS2Object object and press alt+enter it will than import that for you if available.
-
Cant use mouse after activating script
If you try to run a different script after you run yours, than stop it, does it than allow you to toggle the mouse? If so we will need to see more code to find the issue.
-
Blinking widgets, mouse clicks and tut island progress track
Definitely as FuryShark said, configs are a must for any quest like task. I think for tutorial island the config id you will be using is 281. If you want to get a widget based on an interaction you can do something like this: private RS2Widget getWidgetContainingInteraction(String interaction) { for (RS2Widget widget : getWidgets().getAll()) { String[] actions = widget.getInteractActions(); if (actions != null) for (String action : actions) { if (action != null && action.equals(interaction)) return widget; } } return null; }
-
Can't interact with smelting widget
If you dont care about performance you can loop through all the widgets and check the actions to see if the string contains the action than cache that widget so you dont have to re-loop when you interact with it again. IE. If widgetvar is null Loop through widgets than set the widgetvar. Else interact with the widgetvar
-
Fixed code snippet for issue. Please check, thanks
Following the log it definitley is happening once you try to hop worlds.if having the -norandoms fixes this than I would think that the world hop method has a bug in that causes the randoms handler to start and gets stuck since there is no random to solve. Try to crete your own world hop method and see if it fixes it.
-
[n00b] Payment information, trade and multiple accounts
If you didn't use a proxy for the account that got banned than your ip is now flagged and bans will happen more frequently on that ip. I am not sure if they flag email accounts i would guees they would. They do also track items being traded to and from accounts so it is possible your clean account could get banned but i believe they have to manually go in and review the trade history. They most likely wont do that if your not RWTing.
-
Oldschool original client load very slow...
Ddos attacks. https://secure.runescape.com/m=news/old-school-connectivity-issues?oldschool=1
- Elemental Binder [Open Source Runecrafter]
-
HTTP request keeps failing
For checking GE prices you can do it with HttpUrlConnection class. I once used it to compare github version vs the current script version.
-
HTTP request keeps failing
Is this for creating accounts on runescape? If so you could create this as a console app and create a bunch of accounts then dump them into a text file and have your script read from that text file. The file will have to be in the osbot data folder. I think thats the only location that scripts can read/write from.
-
Not withdrawing from bank properly
You need to check if the kebabs are in your inventory before opening the exchange i believe what is happening is that if the bank is not open than you open the bank and than run the next code that would be opening the exchange. So it closes out of the bank before grabbing the kebabs. So something like this. If(getInventory().contains("kebabs") && geClerk != null && geClerk.interact("Exchange")) Take note of the order of which you are checking as well. If the check for null and the check for the ininteraction is before the kebabs it will still exit the bank and try to interact with the clerk. Again sorry for the formating still only have access to my phone atm.
-
Absolute idiot here trying to learn how to create scripts from scratch
There are quite alot of tutorials on here for creating a script. But i would first recommend getting familar with java and how programming works in general. Look up information on object oriented programming and try to create a simple program like a calculator that can add and subtract from user input. While being able to show the history of the past operations. Hope it all goes well. If you need any help feel free to pm me.
-
Not withdrawing from bank properly
Before opening the ge you should also check to see if you have the kebabs. Also the sleep you are doing when you open the ge will end before it is open since you are just waiting for the click. You should change it to wait until the ge is open. Example If (geClerk != null && geClerk.interact("Exchange") Sleep.sleepUntil(() -> getGrandExchange().isOpen()); Sorry for the formating, on my phone atm.
-
Local script not showing up
Example of the script manifest. Place it above your main class: @ScriptManifest(name = "NameOfScript", author = "YourName", version = 1.0, info = "", logo = "")
-
Enter amount Dialogue
Once you are ready to type the input try getKeyboard.typeString(amount);
-
Get # of Positions an entity takes up
Hmmm you could get the direction that the hill giant is facing and than add an extra tile depending on where the second tile that the hill giants use. IE. If the second tile is always infront of the hill giant than take the current tile the hill giant is on and add another one that is infront of the hill giant.