Jump to content

liverare

Scripter II
  • Posts

    1296
  • Joined

  • Last visited

  • Days Won

    3
  • Feedback

    0%

Everything posted by liverare

  1. I know. I supposed a bit of critique I have are: Don't suppress warnings. If you're being told you can reference something statically, you should. Don't add and then modified delegate methods unless it makes sense. The thing I was mocking you for was the fact that 'this.bank.contains' returns a bool and you could have simply returned that in your 'containsItem' method. Similar thing for your 'close' method. OSBot has an InterruptedException handler, so you don't have to add your own. Instead, have your methods throw that exception up the stack. You're effectively making an API, albeit an extension to the Bank API. Instead of defining mouse, keyboard, script, etc. just extend 'org.osbot.rs07.script.API' on your class, instantiate a new object of that class and call its 'exchangeContext' function and 'initialiseModule' function (in that order). That gives you access to all the internal APIs. You can see an example here. Your 'withdrawItem' function is flawed in the human sense. If I have to withdraw 2 of something, I'm not going to be performing a 'withdraw-X', but I bet Jagex performs a little check of players who do. If the action requires maybe more than 5 mouse actions, then perhaps withdraw by X amount. By 5 mouse actions, that includes withdrawing 5 and 10, then left-clicking the rest. Have fun writing that AI.
  2. Alek's simply jealous he'd never thought of: public boolean containsItem(String name) { if (this.bank.contains(name)) { return true; } return false; } Success breeds jealousy.
  3. The next call you make should be with your provider to sort this mess out. If you think you've been grossly overcharged, then state your case with them, see if you can reach an agreement, or if that fails, try and break out of your contract as early as possible. Pay as you go has it's downsides, but ensures that I'm never overcharged. You might wish to consider it.
  4. GUI builders let you pick which layout you want to use. This is important. A null layout will require you to specify the size and position of every component, whereas other layouts (GridBagLayout, BoxLayout, FlowLayout) automatically arrange your components, but you get to specify how they're arranged. You should write your own GUIs from scratch so you can build your GUIs exactly how you need them to be. I've never used that builder, so no comment. You're welcome. You're using a GUI builder. Why would somebody make an advanced tutorial for you when you're not going to learn the how's/why's of the actual underlying code?
  5. Reflection has its uses if you're wanting to do stuff that is potentially risky (that Jagex could detect), such as force-selecting inventory items (like I did for my old Usain Bolter and Darter script when reflection worked), selecting magic spells, and if you can see how prayer works, you could even perhaps bump prayers about programatically.
  6. Items are known constants, so make an enumerator and populate it with relevant items. Enumerators can also have interfaces implemented into them, so you can include an item filter and then simply refer to the entries: public enum ItemData implements Filter<Item> { ABYSSAL_WHIP(4151, "Abyssal whip"), COINS(995, "Coins"), ; private final int id; private final String name; private ItemData(int id, String name) { this.id = id; this.name = name; } @Override public String toString() { return String.format("[%s] %s", id, name); } @Override public boolean match(Item item) { return item.getId() == id || item.getName().equals(name); } public int getId() { return id; } public String getName() { return name; } } Then you can do: Item item1 = inventory.getItem(ItemData.ABYSSAL_WHIP); Item item2 = inventory.getItem(ItemData.values());
  7. Note: this is not how to make a GUI. This is how to implement one. The following is assumed: You have one file that contains your GUI code. You have one file that contains your script code. Your GUI code has a 'start' button which is public or has a getter function. Let's start with your script code: public class TestScript extends Script { @Override public void onStart() throws InterruptedException { } @Override public int onLoop() throws InterruptedException { return 250; } @Override public void onExit() throws InterruptedException { } } Simple code with three routines: onStart, onLoop and onExit. Here's what we're going to do: onStart Check the script parameters and store the values into Atomic variables. I'll explain why later. If we don't have script parameters, we then initialise the GUI and then show it. onLoop If our Atomic variables are empty, then have the script do some afk things (shake the mouse) until we do. If the user closes the GUI and our Atomic variables are empty, then stop the script. onExit If the GUI exists, then dispose of it. Okay, so now let's begin by declaring some variables: public class TestScript extends Script { private JFrame gui; private String params; private AtomicReference<String> treeName; private AtomicReference<String> axeName; private AtomicBoolean powerchop; private AtomicInteger stopAtLevel; @Override public void onStart() throws InterruptedException { initialiseVars(); } public void initialiseVars() { params = super.getParameters(); treeName = new AtomicReference<>(); axeName = new AtomicReference<>(); powerchop = new AtomicBoolean(); stopAtLevel = new AtomicInteger(); } @Override public int onLoop() throws InterruptedException { return 250; } @Override public void onExit() throws InterruptedException { } } Notice how I haven't instantiated the 'gui' variable? This is intentional. GUIs are inefficient and memory intensive. If the user has started the script with script parameters, then just use that. However, if the script parameters are wrong, then use the GUI as backup. Now let's check the script parameters and initialise the GUI. Note: how you check script parameters are valid is up to you. You can check out my CLI Support Made Easy API API, Script File (ini) API, and OSBot File API. public class TestScript extends Script { private JFrame gui; private String params; private AtomicReference<String> treeName; private AtomicReference<String> axeName; private AtomicBoolean powerchop; private AtomicInteger stopAtLevel; @Override public void onStart() throws InterruptedException { initialiseVars(); if (!checkScriptParameters()) { SwingUtilities.invokeLater(this::initialiseGUI()); } } private void initialiseVars() { params = super.getParameters(); treeName = new AtomicReference<>(); axeName = new AtomicReference<>(); powerchop = new AtomicBoolean(); stopAtLevel = new AtomicInteger(); } private boolean checkScriptParameters() { boolean valid = false; // TODO check script parameters // TODO put values into Atomic variables (parse them if need be) // TODO return true/false based on whether the parameters were correct return valid; } private void initialiseGUI() { // TODO gui stuff } @Override public int onLoop() throws InterruptedException { return 250; } @Override public void onExit() throws InterruptedException { } } So, about those Atomic variables. Notice the "SwingUtilities.invokeLater..." stuff? Well, you can read about Swing Utilities here. The short-form is: we're running the GUI on a separate thread. This means the following: The client won't freeze whilst the GUI is open (yay!). The Atomic variables are going to handle all that messy concurrency stuff that is now an issue because we're using a separate thread for stuff. Without Atomic variables, we'd need to add our own thread-safety. Why? Because if your script changes a variable at the exact same moment your GUI decides to update that variable, the script thread and GUI threads will conflict and things break. Praise be to Atomic variables! Also, if you're wondering what the :: is for, you can read about that here. The short and sweet: it's a way of referencing a method. Okay now, let's do GUI stuff! Right, we're going to need to add a method that grabs user input from GUI and stores it into the Atomic references. public class TestScript extends Script { private JFrame gui; private String params; private AtomicReference<String> treeName; private AtomicReference<String> axeName; private AtomicBoolean powerchop; private AtomicInteger stopAtLevel; @Override public void onStart() throws InterruptedException { initialiseVars(); if (!checkScriptParameters()) { SwingUtilities.invokeLater(this::initialiseGUI()); } } private void initialiseVars() { params = super.getParameters(); treeName = new AtomicReference<>(); axeName = new AtomicReference<>(); powerchop = new AtomicBoolean(); stopAtLevel = new AtomicInteger(); } private boolean checkScriptParameters() { boolean valid = false; // TODO check script parameters // TODO put values into Atomic variables (parse them if need be) // TODO return true/false based on whether the parameters were correct return valid; } private void initialiseGUI() { gui = new MySexyGUI(); gui.setLocationRelativeTo(bot.getCanvas()); gui.addWindowListener(new WindowAdapter() { @Override public void windowClosing(WindowEvent e) { TestScript.super.stop(false); } }); gui.getStartButton().addActionListener(this::startButtonClicked); gui.setVisible(true); } private void startButtonClicked(ActionEvent e) { String treeName = gui.getTreeNameTextField().getText(); String axeName = gui.getAxeNameTextField().getText(); boolean powerChop = gui.getPowerChopCheckBox().isSelected(); int stopAtLevel = (int) gui.getStopAtLevelNumberSpinner().getValue(); if (treeName != null && !treeName.isEmpty() && axeName != null && !axeName.isEmpty()) { this.treeName.set(treeName); this.axeName.set(axeName); this.powerchop.set(powerChop); this.stopAtLevel.set(stopAtLevel); gui.setVisible(false); } else { // TODO let the user know there are problems in the GUI } } @Override public int onLoop() throws InterruptedException { return 250; } @Override public void onExit() throws InterruptedException { } } Once we've grabbed the information from the GUI, we need to make sure it's correct. For things such as tree names, axe names, or any other constants, I'd have an enumerator that contains those values and let the user pick out them values from a combo box. It's a safer bet as the user can't pick a "wrong" tree and the enumerator can be used in the checking of the script parameters. If our values are correct, we then store them into the Atomic variables and then hide the GUI. We could dispose of the GUI at this point. However, if the GUI has already been initialised, you may as well keep it around so the user can make real-time changes to the behaviour of the script. I've positioned the GUI relative to the bot's canvas and also added a WindowListener in the form of a WindowAdapter to the GUI that will stop the script if the user clicks on the close button. These are pretty expectant behaviour, so I'd figure I'd add them. To recap, we've achieved the following: onStart Check the script parameters and store the values into Atomic variables. If we don't have script parameters, we then initialise the GUI and then show it. But also, we've achieved this as well: onLoop If the user closes the GUI and our Atomic variables are empty, then stop the script. Because the GUI has a listener that listens to the close button. If that button is clicked, the script will then stop. But we're not done with our onLoop just yet! We're going to want to figure out what values we're currently working with. public class TestScript extends Script { private JFrame gui; private String params; private AtomicReference<String> treeName; private AtomicReference<String> axeName; private AtomicBoolean powerchop; private AtomicInteger stopAtLevel; @Override public void onStart() throws InterruptedException { initialiseVars(); if (!checkScriptParameters()) { SwingUtilities.invokeLater(this::initialiseGUI()); } } private void initialiseVars() { params = super.getParameters(); treeName = new AtomicReference<>(); axeName = new AtomicReference<>(); powerchop = new AtomicBoolean(); stopAtLevel = new AtomicInteger(); } private boolean checkScriptParameters() { boolean valid = false; // TODO check script parameters // TODO put values into Atomic variables (parse them if need be) // TODO return true/false based on whether the parameters were correct return valid; } private void initialiseGUI() { gui = new MySexyGUI(); gui.setLocationRelativeTo(bot.getCanvas()); gui.addWindowListener(new WindowAdapter() { @Override public void windowClosing(WindowEvent e) { TestScript.super.stop(false); } }); gui.getStartButton().addActionListener(this::startButtonClicked); gui.setVisible(true); } private void startButtonClicked(ActionEvent e) { String treeName = gui.getTreeNameTextField().getText(); String axeName = gui.getAxeNameTextField().getText(); boolean powerChop = gui.getPowerChopCheckBox().isSelected(); int stopAtLevel = (int) gui.getStopAtLevelNumberSpinner().getValue(); if (treeName != null && !treeName.isEmpty() && axeName != null && !axeName.isEmpty()) { this.treeName.set(treeName); this.axeName.set(axeName); this.powerchop.set(powerChop); this.stopAtLevel.set(stopAtLevel); gui.setVisible(false); } else { // TODO let the user know there are problems in the GUI } } @Override public int onLoop() throws InterruptedException { String treeName = this.treeName.get(); String axeName = this.axeName.get(); if (treeName == null || treeName.isEmpty() || axeName == null || axeName.isEmpty()) { // TODO go afk } else { // TODO botty stuff } return 250; } @Override public void onExit() throws InterruptedException { } } The 'onLoop' should be happy as long as you programmed your 'checkScriptParameters' function works. Why? Because if the user enters in wrong script parameters, then the GUI should show up to save the day. If the GUI doesn't show up, that's because the user has entered in correct script parameters, so 'treeName' and 'axeName' should both be valid. Now, let's finish this by closing our GUI on the onExit: public class TestScript extends Script { private JFrame gui; private String params; private AtomicReference<String> treeName; private AtomicReference<String> axeName; private AtomicBoolean powerchop; private AtomicInteger stopAtLevel; @Override public void onStart() throws InterruptedException { initialiseVars(); if (!checkScriptParameters()) { SwingUtilities.invokeLater(this::initialiseGUI()); } } private void initialiseVars() { params = super.getParameters(); treeName = new AtomicReference<>(); axeName = new AtomicReference<>(); powerchop = new AtomicBoolean(); stopAtLevel = new AtomicInteger(); } private boolean checkScriptParameters() { boolean valid = false; // TODO check script parameters // TODO put values into Atomic variables (parse them if need be) // TODO return true/false based on whether the parameters were correct return valid; } private void initialiseGUI() { gui = new MySexyGUI(); gui.setLocationRelativeTo(bot.getCanvas()); gui.addWindowListener(new WindowAdapter() { @Override public void windowClosing(WindowEvent e) { TestScript.super.stop(false); } }); gui.getStartButton().addActionListener(this::startButtonClicked); gui.setVisible(true); } private void startButtonClicked(ActionEvent e) { String treeName = gui.getTreeNameTextField().getText(); String axeName = gui.getAxeNameTextField().getText(); boolean powerChop = gui.getPowerChopCheckBox().isSelected(); int stopAtLevel = (int) gui.getStopAtLevelNumberSpinner().getValue(); if (treeName != null && !treeName.isEmpty() && axeName != null && !axeName.isEmpty()) { this.treeName.set(treeName); this.axeName.set(axeName); this.powerchop.set(powerChop); this.stopAtLevel.set(stopAtLevel); gui.setVisible(false); } else { // TODO let the user know there are problems in the GUI } } @Override public int onLoop() throws InterruptedException { String treeName = this.treeName.get(); String axeName = this.axeName.get(); if (treeName == null || treeName.isEmpty() || axeName == null || axeName.isEmpty()) { // TODO go afk } else { // TODO botty stuff } return 250; } @Override public void onExit() throws InterruptedException { if (gui != null) { SwingUtilities.invokeLater(gui::dispose); } } } Boom. If the user stops the script whilst the GUI is open, the GUI will be dismissed. We've used SwingUtilities again because the GUI is still running on a separate thread, so we should avoid the script from interacting with it directly. Have fun! Let me know if there are any problems. I wrote this adhoc so there were a few things I missed out, which include: Showing the GUI on 'initialiseGUI' (lol). Hiding the GUI when you click on 'startButtonClicked', but only once you've validated the input from the GUI.
  8. I don't think this will work. It won't take long for Jagex to realise there's a chorus of gold farmers lying to get their accounts unbanned when they inspect the levels and actives of those accounts. Then Jagex will simply dismiss the thread.
  9. I wouldn't shove your GUI code in with your script code, otherwise it'll get unwieldy. You can download my glassblowing script to see how I implemented my GUI:
  10. Turn off paint renderings. Try to turn off as many action recordings as possible (wheel, keys, etc.) for things you're not using. I'll do some research in a bit to see how the architecture can be changed to make it more efficient. Having all your actions stored in the RAM is inefficient, especially when recording sessions can be upwards of 20 minutes. It might be necessary to introduce a buffered approach and perhaps even figure out how to shave off unnecessary actions. Because if you were to compare your macro file to another macro programme, you'll notice a lot get saved that makes no sense.
  11. liverare

    Combat Helper

    Item monitor - alert when valuable items appear (check this out) Mod monitor - alert when mods are nearby Streamer monitor - alert when some streamer is nearby so you can photo-bomb them Random event monitor Dead/Idle/logout monitor - alert if you've been killed, idle for a certain amount of time, or have been logged out Looter monitor - similar to item monitor, except it alerts you if someone died wearing some good stuff Managing Miscellania monitor - alerts you if your favour has dropped below % "Bot" "Report" monitor - alerts you when someone starts talking shit Population monitor - alerts you if suddenly you're swarmed by other players for some unknown reason Cat monitor - alerts you when your kitty needs feeding and attention Update monitor - alerts you when the game's about to update Grand Exchange monitor - alerts you when dem monies make dat bank Also, if you need a way to block user input clicks then you can check this out: I wrote
  12. liverare

    Combat Helper

    Awesome script! Also, that notification looks incredibly familiar. Is this the system notification thing I posted here? Because if so, I love what you've done with it!
  13. I don't manage the books. You'll need to ask @Maldesto, but I'm sure he'll be able to sort you out with a refund.
  14. Hi, there appears to be a problem with the 'fast keyboard' setting which I will aim to address later. This may be causing your issues. If you start the script, untick the option for fast keyboard and then confirm the GUI, then the bot should work fine. The overall aim of this script is to turn one of your RuneScape characters into an announcement bot for clan chats, whereby you say "!sg" or another game command, and that bot detects it and responds. Gambling clans use these bots as substitutes to the old dice bag, mithril seeds, etc. Can you try again please and let me know if you're continuing to have issues. Thanks! -Live
  15. Ran out of membership. ? I need proggies though!
  16. The greatest anti-ban in existence! There's no way in hell JaGeX would suspect you of botting with this beauty. It's so ingenious, I'm surprised nobody's ever done it before.
  17. Download link below. Shitpost: The most enhanced human auto-chat AI in existence. Display CLI example: -script Shitpost:POL (find boards here) Source files included in the JAR. You can view the contents of JAR files with Winrar. Run at your own risk. I'm not responsible if you get banned, muted, or a visit by the police. Shitpost.jar
  18. That's nothing to be proud of. There were over 10 cops on the scene to apprehend one fucking guy with a machete. God forbid there's 10,000 people with machetes. Also, the UK is in massive debt and we can't afford to pay our police to piss about trying to apprehend lunatics like this.
  19. I'm sure the victims of Telford and Rotherham feel the same too.
  20. School shootings are an American phenomenon and going by the stats starting from 2010 (https://en.wikipedia.org/wiki/List_of_school_shootings_in_the_United_States#2010–2014), a little Excel later and the average number of fatalities in school shootings is 1.05 and average injuries is 1.62. It's only ever the mass murders, like at Sandy Hook and Douglas High School that get any real kind of media attention. I won't bother comparing those numbers to the numbers of deaths by vehicles, cancer, obesity world wide. For shit and giggles, let's say the total number to-date of all murders and injuries in school shootings has reached 1 million, that's still a piss in the ocean when the population of USA is estimated around 320 million. So it's rare and it's inconsequential. Even the other mass murders by shootings adds fuck all to the overall numbers. Shootings are rare and inconsequential, but when they do happen, it's by and large gang-related violence, or suicide by cop. It's certainly not worth burning the 2nd amendment over.
  21. Mass shootings != mass murder. The majority of gun violence happen in inner-cities, not in Cletus-country. School shootings are very rare and death toll negligible. UK has very strict gun laws, but we also have rape gangs that have operated with impunity for decades.
  22. Pretty ingenious script. Perhaps make it so you only report someone's whereabouts after you've hopped over to an empty world? Because you might spook your pray. If I see a level-3 just standing there, I'm going to tense up a little, y'know. But if I see that white dot flicker out of existence, meh, all's good (apparently. ).
  23. Are we talking guns you hold properly, or guns you hold sideways with your other hand grabbing your nuts?
  24. public enum Task { OPEN_BANK("Open bankies") { @Override public boolean validate(Bot bot) { return !bot.bank.isOpen(); } @Override public int execute(Bot bot) throws InterruptedException { if (bot.bank.open()) { bot.logger.debug("*YAY*"); } return 250; } } ; private final String name; private Task(String name) { this.name = name; } public abstract boolean validate(Bot bot); public abstract int execute(Bot bot) throws InterruptedException; @Override public String toString() { return name; } }
  25. https://stackoverflow.com/jobs Do some research and find out which jobs pay the most for which programmer. I wouldn't ask around here, because Java is the language this bot's developed in and scripts are written for. You're going to get a very biased reception.
×
×
  • Create New...