Jump to content

Explv

Scripter II
  • Posts

    2314
  • Joined

  • Last visited

  • Days Won

    6
  • Feedback

    100%

Everything posted by Explv

  1. First of all it should be: myPlayer().getName() Not: getPlayers().myPlayer().getName() Secondly you don't compare Strings using ==. == Checks that the references are equal, not the values. To check the values of Strings for equality you should use .equals(): myPlayer().getName().equals(MULE_NAME) Example: String string1 = new String("hi"); String string2 = new String("hi"); string1 == string2 // false, string1 is a different instance to string2 string1 == string1 // true, string1 is the same instance as string1 string1.equals(string2) // true, the value of string1 is equal to the value of string2 If there is a space in the username you _may_ need to do this to replace non-breaking spaces: (I cant remember if you actually need to do this or not in this case) myPlayer().getName().replace('\u00A0', ' ').equals(MULE_NAME) Also you have named the mule name variable as MULE_NAME, yet the value is not a constant. It should be: private static final String MULE_NAME = "displayname"; This will not affect functionality, but it is best practice. Finally you say that you are using this getJob() function every loop. I would recommend you only call it once in onStart() because the username isn't going to change throughout the script's lifetime. (Unless the script changes accounts)
  2. Yes simpler = better in 99.9% of cases The "Task" pattern that was promoted here is stupid, and so is the whole switch state rubbish. Would also recommend Clean Code by Robert C. Martin https://books.google.co.uk/books/about/Clean_Code.html?id=hjEFCAAAQBAJ&source=kp_book_description&redir_esc=y And The Pragmatic Programmer https://en.wikipedia.org/wiki/The_Pragmatic_Programmer
  3. Look at the following sections on the tutorial: Starting the experience tracker Using the experience tracker It's very clear, you start the experience tracker in onStart, and then you use the getGainedXP function in your onPaint to get the gained XP
  4. Look at the following sections on the tutorial: Drawing text on screen Starting the experience tracker Using the experience tracker (optional) Formatting money and XP
  5. Here is another example using Python: import subprocess OSBOT_PATH = "C:\\Users\\Explv\\Downloads\\OSBot 2.5.22.jar" OSBOT_USER = "" OSBOT_PASS = "" def main(): cmd = ["java", "-jar", OSBOT_PATH, "-login", OSBOT_USER + ":" + OSBOT_PASS, "-debug"] popen = subprocess.Popen(cmd, stdout=subprocess.PIPE, universal_newlines=True) prev_pids = get_java_pids() for stdout_line in iter(popen.stdout.readline, ""): print(stdout_line) if "Successfully loaded OSBot!" in stdout_line: break popen.stdout.close() new_pids = get_java_pids() current_osbot_pid = new_pids - prev_pids if len(current_osbot_pid) > 1: raise ValueError('More than one new Java PID found') print("OSBot PID is: " + next(iter(current_osbot_pid))) def get_java_pids(): pids = set() java_processes = subprocess.check_output("tasklist /FI \"IMAGENAME eq java.exe\" /NH") for java_process in java_processes.decode('utf-8').splitlines(): if len(java_process.strip()) > 0: pid = java_process.split()[1] pids.add(pid) return pids if __name__ == '__main__': main()
  6. OK that's fine, probably what isn't working for you is the fact that OSBot starts two processes. The first process is the boot menu where you type your login details. When you click login, a new process is started for the actual client, and the boot menu process exits. For example: # Boot menu opens C:\Users\Explv>tasklist /FI "IMAGENAME eq java.exe" /NH java.exe 5304 Console 2 51,772 K # Client opens C:\Users\Explv>tasklist /FI "IMAGENAME eq java.exe" /NH java.exe 15692 Console 2 37,620 K You have two options: 1. Add a sleep long enough to let OSBot boot up properly and for the client to open, and then get the PIDs or 2 (recommended) Use Python/Java/Whatever programming language to run OSBot (in debug mode) and read the output. When the output contains "Successfully loaded OSBot!" you know that the client has fully booted and you can get the PID using tasklist. Here is an example I wrote in Java https://github.com/Explv/osbot_manager/blob/master/osbot_manager/src/bot_parameters/configuration/Configuration.java#L347
  7. How are you starting the OSBot processes and getting the PIDs? show your code And no, the PID of a given process does not change throughout that process' lifetime.
  8. Are you using injection or mirror mode? Also try the following: public boolean set(PrayerButton prayer, boolean activate) { if (getPrayer().isActivated(prayer) == activate || !getPrayer().hasLevelFor(prayer)) { return false; } if (!getPrayer().open()) { return false; } List<RS2Widget> prayerWidgets = getWidgets().containingSprite(541, prayer.getSpriteId()); if (!prayerWidgets.isEmpty() && prayerWidgets.size() <= 1) { return prayerWidgets.get(0).interact(activate ? "Activate" : "Deactivate"); } else { warn("A problem was encountered with identifying prayer button for " + prayer.toString()); return false; } }
  9. Ok, so that indicates that this block of code, is not working for you: if (prayerRootID == -1) { Optional<RS2Widget> prayerIconWidget = getWidgets().getAll() .stream() .filter(w -> w.getSpriteIndex1() == Sprites.PRAYER_ICON_INSIDE_TAB) .findFirst(); if (!prayerIconWidget.isPresent()) { return false; } prayerRootID = prayerIconWidget.get().getRootId(); log("Found prayer root ID: " + prayerRootID); } That's strange because it works just fine for me: [INFO][Bot #1][09/23 11:35:17 AM]: Found prayer root ID: 541 Are you running mirror mode or injection? Also I missed the following line from my original snippet: private static int prayerRootID = -1 Make sure you have that as a variable if you don't already (refer to my updated snippet in the previous comment)
  10. A sprite is: https://en.wikipedia.org/wiki/Sprite_(computer_graphics) In this case the sprite is the little sword icon for the prayer, and the sprite ID uniquely identifies that sprite. Ok so you say the sprite ID is 129, which is correct, there must be another issue here. Here is (roughly) the OSBot Prayer.set function, with some added debug log statements. Try using this function instead of the OSBot version, and tell me what the output in the log is. Maybe we can figure out what's breaking. private static int prayerRootID = -1; public boolean set(PrayerButton prayer, boolean activate) { if (getPrayer().isActivated(prayer) == activate || !getPrayer().hasLevelFor(prayer)) { return false; } if (!getPrayer().open()) { return false; } if (prayerRootID == -1) { Optional<RS2Widget> prayerIconWidget = getWidgets().getAll() .stream() .filter(w -> w.getSpriteIndex1() == Sprites.PRAYER_ICON_INSIDE_TAB) .findFirst(); if (!prayerIconWidget.isPresent()) { return false; } prayerRootID = prayerIconWidget.get().getRootId(); log("Found prayer root ID: " + prayerRootID); } List<RS2Widget> prayerWidgets = getWidgets().containingSprite(prayerRootID, prayer.getSpriteId()); log("Found prayer button widgets: " + Arrays.toString(prayerWidgets.toArray())); if (prayerWidgets.size() == 1) { return prayerWidgets.get(0).interact(activate ? "Activate" : "Deactivate"); } else { warn("A problem was encountered with identifying prayer button for " + prayer.toString()); return false; } }
  11. The API looks for the protect from melee prayer using the sprite ID 129. The warning is raised when either no widget with that sprite ID is found, or more than 1 widget with that sprite ID is found. I don't have 43 prayer, so I cannot determine if this sprite ID is correct. I think the sprite ID is different if the prayer is disabled (for me it's 149). What you should do is debug the widget (541, 18, 1) using the widget debugger in the client (Settings -> Options -> Widget Debugger) and look at the value of Sprite ID 1 (enabled). If you have 43 prayer, and you are able to toggle protect from melee on and off, and the sprite ID is not 129, then you should file a bug report. Either way post here what you find.
  12. Explv

    "Or" ||

    I mean, there aren't snippets of this for the same reason there aren't snippets of how to use a for loop, or what an int is. It's covered in basic Java tutorials, and doesn't need to be repeated here.
  13. You're most likely building the wrong .jar Or you somehow have two scripts with the same name in your scripts folder, so it's always picking up the old one. Try moving everything out of your scripts folder and rebuilding.
  14. @Luke Reading Just keep track of the percentage changed / number of decrease price clicks. For example: final int targetPercentageChanged = -10; execute(new Event() { int percentageChanged = 0; @Override public int execute() throws InterruptedException { if (percentageChanged != targetPercentageChanged) { if (targetPercentageChanged < 0) { if (lower5PercentWidget.interact()) { percentageChanged -= 5; } else if (higher5PercentWidget.interact()) { percentageChanged += 5; } } } else if (getGrandExchange().confirm()) { setFinished(); } return 600; } });
  15. Give away closed. Congrats @Evade, I will pm you
  16. Got a beta code to give away Like thread to enter Random person will be picked @ 6pm GMT
  17. Explv

    Explv's Walker

    Might be helpful if you tell me what "loc" is supposed to mean.
  18. https://www.quora.com/Which-are-the-best-books-to-learn-C Common book people get is "The C Programming Language", a complete PDF can be found online if you want to take a look at the contents: http://www.dipmat.univpm.it/~demeio/public/the_c_programming_language_2.pdf
  19. Explv

    Explv's Walker

    I'm on holiday atm, back tomorrow, will take a look when I'm back.
  20. Player will still interact with trees outside of the Area, and end up walking back and forth being super confuse, unless you filter the objects with an AreaFilter. May want to updoot ur answer to demonstrate.
  21. If you bot, there's a possibility you get banned. Doesn't matter what script it is.
×
×
  • Create New...