Jump to content

Search the Community

Showing results for tags 'Intermediate'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • OSBot
    • News & Announcements
    • Community Discussion
    • Bot Manager
    • Support Section
    • Mirror Client VIP
    • Script Factory
  • Scripts
    • Official OSBot Scripts
    • Script Factory
    • Unofficial Scripts & Applications
    • Script Requests
  • Market
    • OSBot Official Voucher Shop
    • Currency
    • Accounts
    • Services
    • Other & Membership Codes
    • Disputes
  • Graphics
    • Graphics
  • Archive

Product Groups

  • Premium Scripts
    • Combat & Slayer
    • Money Making
    • Minigames
    • Others
    • Plugins
    • Agility
    • Mining & Smithing
    • Woodcutting & Firemaking
    • Fishing & Cooking
    • Fletching & Crafting
    • Farming & Herblore
    • Magic & Prayer
    • Hunter
    • Thieving
    • Construction
    • Runecrafting
  • Donations
  • OSBot Membership
  • Backup

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


MSN


Website URL


ICQ


Yahoo


Skype


Location:


Interests

Found 16 results

  1. My friends found a sick way to make money buying stuff from an npc shop, now it's been some time since i last coded something and i'm looking someone to tell me am i missing some events here. > If inventory is !full, go to npc and trade. > Buys till the stock is empty or inventory is full and banks > If stock is empty == hop Thanks!
  2. boolean examined = false; List<RS2Object> allEntities = new ArrayList<RS2Object>(); allEntities = objects.getAll(); do { RS2Object obj = allEntities.get(random(0, allEntities.size() - 1)); if (obj != null && obj.hasAction("Examine")) { obj.interact("Examine"); examined = true; log(obj.getName() + " examined."); } } while (!examined); I am trying to get a list of all the entities around me and examine one at random. I seem to be able to get a random object just fine, but it never actually gets past this part. if (obj != null && obj.hasAction("Examine")) { Any ideas why?
  3. Title pretty much says it all. Character needs to sleep, when combining items. Character doesn't do an animation. Some sort of inventory listener?
  4. I was looking over Pandemic's guide on a simple mining script http://osbot.org/forum/topic/29924-pandemics-scripting-series-part-ii-path-walking-and-simple-banking-updated-for-osbot-2/?hl=banking And it was all making sense to me except when it had finally come together I had some errors, import org.osbot.rs07.utility.Area; This line was couldn't be resolved, this ended up effecting any othertime when the word Area was used. The guide was written in 2014 and OSBot has been updated since then, I'm not sure how to use the Area function. Thanks for any help you can provide!
  5. Getting back into coding, and it's been a long time :p lol Short story short, I want to test out my script, but I need it in a .jar How do I build the script to a .jar file through IntelliJ . I know there is a way, did it in the past. Any help is awesome
  6. So this is going to be a beginners guide into utilizing a walking function. This is by all means a standard walker and doesn't support any objects blocking path, different types of objects could be in your way so for sake of simplicity i'll leave it out and if you'd like just request me to do a snippet on walking with object interacts, etc.. Suggest me any script and I can probably do it (still learning some small stuff, but majority is pretty ez pz). Firstly, i'd like you to just read the bullet points below, then read the code and understand the functions, and not get overwhelmed by something that you may not understand at first okay; take your time to understand the functions and ways around the OSB API. If you have any questions feel free to PM me or post on my profile wall, etc.. always willing to help with my current knowledge. For coordinations I just use: https://explv.github.io/ (source code Javascript: https://github.com/Explv/Explv.github.io) credits: Explv Position (this is our destination in where we're trying to head towards automatically for us instead of that long grind in walking. Includes a script run time length Supports the Run function for the player (set Run on startup, also comes with a random chance for run checking) Dismisses the pesky random events that pop up sometimes, also stores an integer value that increments every time we dismiss one For sake of a anti ban like method moving our Mouse to -1,-1 coordinates will make it look like a human like AFK (TODO: Test) If the player is under attack, the player will activate Run mode and will continue to run to destination regardless Standard String drawing for paint (displays any info we collect through variables(example: run time, events dismissed)) package main.script.Bot_Walker; import java.awt.BasicStroke; import java.awt.Color; import java.awt.Font; import java.awt.Graphics; import java.awt.Graphics2D; import java.awt.Point; import java.awt.RenderingHints; import java.text.NumberFormat; import org.osbot.rs07.api.map.Position; import org.osbot.rs07.api.model.NPC; import org.osbot.rs07.script.Script; public class AutoWalker extends Script { private long timeStarting = System.currentTimeMillis(); private int randomsDismissed; private Position destination = new Position(3222, 3222, 0); @[member=Override] public void onStart() throws InterruptedException { log("Starting up the bot walking"); timeStarting = System.currentTimeMillis(); getSettings().setRunning(true); } private boolean dismissRandom() { for (NPC randomEvent : npcs.getAll()) { if (randomEvent == null || randomEvent.getInteracting() == null || randomEvent.getInteracting() != myPlayer()) { continue; } if (randomEvent.hasAction("Dismiss")) { randomEvent.interact("Dismiss"); randomsDismissed++; return true; } } return false; } @[member=Override] public int onLoop() throws InterruptedException { int randomRun = random(5); if (randomRun == 1) { getSettings().setRunning(getSettings().getRunEnergy() < 25 ? false : true); } if (dismissRandom()) { while (myPlayer().isMoving()) { sleep(random(600, 800)); } } while (myPlayer().isAnimating()) { mouse.move(-1, -1); } if (myPlayer().isUnderAttack()) { getSettings().setRunning(true); getWalking().webWalk(destination); } getWalking().webWalk(destination); return random(200, 300); } @[member=Override] public void onPaint(Graphics2D graphics) { drawMouse(graphics); Font font = new Font("TimesRoman", Font.PLAIN, 12); graphics.setFont(font); graphics.setColor(Color.WHITE); graphics.drawString("Auto Walker script created by: Booleans Yay", 140, 325); graphics.drawString("Randoms Dismissed: " + formatIntegers(randomsDismissed), 5, 55); long runTime = System.currentTimeMillis() - timeStarting; graphics.drawString("Script Runtime: " + formatTime(runTime), 5, 85); } private void drawMouse(Graphics graphics) { ((Graphics2D) graphics).setRenderingHints( new RenderingHints(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON)); Point pointer = mouse.getPosition(); Graphics2D spinG = (Graphics2D) graphics.create(); Graphics2D spinGRev = (Graphics2D) graphics.create(); spinG.setColor(new Color(255, 255, 255)); spinGRev.setColor(Color.cyan); spinG.rotate(System.currentTimeMillis() % 2000d / 2000d * (360d) * 2 * Math.PI / 180.0, pointer.x, pointer.y); spinGRev.rotate(System.currentTimeMillis() % 2000d / 2000d * (-360d) * 2 * Math.PI / 180.0, pointer.x, pointer.y); final int outerSize = 20; final int innerSize = 12; spinG.setStroke(new BasicStroke(1.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND)); spinGRev.setStroke(new BasicStroke(1.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND)); spinG.drawArc(pointer.x - (outerSize / 2), pointer.y - (outerSize / 2), outerSize, outerSize, 100, 75); spinG.drawArc(pointer.x - (outerSize / 2), pointer.y - (outerSize / 2), outerSize, outerSize, -100, 75); spinGRev.drawArc(pointer.x - (innerSize / 2), pointer.y - (innerSize / 2), innerSize, innerSize, 100, 75); spinGRev.drawArc(pointer.x - (innerSize / 2), pointer.y - (innerSize / 2), innerSize, innerSize, -100, 75); } public static String formatIntegers(int number) { return NumberFormat.getInstance().format(number); } public final String formatTime(final long milisecond) { long s = milisecond / 1000, m = s / 60, h = m / 60, d = h / 24; s %= 60; m %= 60; h %= 24; return d > 0 ? String.format("%02d:%02d:%02d:%02d", d, h, m, s) : h > 0 ? String.format("%02d:%02d:%02d", h, m, s) : String.format("%02d:%02d", m, s); } }
  7. So hey OSBot, even though I'll probably get called a leecher like I was in my last thread lol, I'm having another issue. I've finished my cowhide script, and it's pretty efficient. Fills an inventory in about 2 mins (~100k/hr profit), but I want to record how many of the hides I've actually picked up. My paint includes the time ran, but I want to know how many hides I've looted in that time. How do I know if I actually picked that hide up, since 1 out of 3 hides my script goes after are looted by other people. Any ideas?
  8. Hey OSBot, I'm writing my first script currently. I've figured out walking, areas, and (some) entity interaction, but I'm not super sure on how to pick up a ground item. What I want is for onLoop() to check region if a ground item with name/id exists (isValid?) and simply "Take" it. I can't even figure out how to iterate through the List<GroundItems> or if that's how to do it in the first place. Not very good at reading javadocs lol. Thanks in the future, OSBot.
  9. It's a basic short and simple system. I'm learning the API so please if you have any additional ideas and things to add or guides or anything I can use to better myself and my scripts please PM me or reply here!! Script Features: Camera Movement Picks up full inventory of Bones to bury Hoping to add more! Jar: https://mega.nz/#!1R11TTjJ!WkjkMtG6EU-c-k0StJGnVVLgA4nIUiGP1xP4tTJwBnM Raw: https://paste.ee/p/2ZRLP package main.script; import java.awt.Graphics2D; import org.osbot.rs07.api.model.GroundItem; import org.osbot.rs07.api.model.Item; import org.osbot.rs07.script.Script; import org.osbot.rs07.script.ScriptManifest; @ScriptManifest(author = "Booleans Yay", info = "Bone burying made ez pz", name = "Bone Bury", version = 1, logo = "") public class BoneBury extends Script { @[member='Override'] public void onStart(){} private enum BotState { PICKUP, BURY }; private BotState getState() { return inventory.isFull() ? BotState.BURY : BotState.PICKUP; } @[member='Override'] public int onLoop() throws InterruptedException { switch (getState()) { case PICKUP: if (!myPlayer().isAnimating()) { GroundItem bone = groundItems.closest("Bones"); if (bone != null) { bone.interact("Take"); Thread.sleep(random(1500)); } } break; case BURY: camera.moveYaw(random(360)); while (!inventory.isEmpty()) { Item bones = inventory.getItem("Bones"); if (bones != null) { bones.interact("Bury"); if (myPlayer().isAnimating()) { bones.interact("Bury"); Thread.sleep(random(200)); } } } break; } return random(200, 300); } @[member='Override'] public void onExit(){} @[member='Override'] public void onPaint(Graphics2D g){} }
  10. Yo what do I return in onLoop when i want to stop the script? I tried returning -1 but that just crashed osbot.
  11. I've decided to make this system, due to my dislike of the way that most scripts are being made and the fact that I come from an environment where everything is truly event based. This tutorial will depend on a system that I wrote (OSBotEventSystem), which you can find on GitHub here. Documentation can also be found on my website here. What is an event system? An event system is a system that allows you to subscribe (listen) to certain events. Events are fired whenever something specific happens. The outcome of the event is driven by the listening subscribers (EventHandlers) and will allow you to fire whatever code you want, whenever the event that you're listening for fires. You can read about Event-driven programming here, if you need a proper understanding of the subject. What are the benefits of an event system? The benefits of an event system, allows you to manage and maintain your code much easier. You'll be able to easily tell your code in what order, your subscribers are going to be executed. And much... much... more. Step #1 We're going to start off by adding the event system to our build path (this has to be compiled with your script). I've added this to a maven repository, so it should be easy for anyone to go ahead and add this to your pom, build.gradle or heck! even just a simple jar file. I expect you to already know how to add a dependency to your IDE of choice, so I'm just going to provide your with the repositories, artifacts and links. Gradle repository maven { name 'Puharesource' url 'http://repo.puha.io/nexus/content/repositories/releases/' } Gradle artifact compile group: 'io.puharesource.osrs', name: 'eventsystem', version: '1.0.1' Maven repository <repository> <id>puha-repo</id> <url>http://repo.puha.io/nexus/content/repositories/releases/</url> </repository> Maven dependency <dependency> <groupId>io.puharesource.osrs</groupId> <artifactId>eventsystem</artifactId> <version>1.0.1</version> </dependency> Jar file http://repo.puha.io/nexus/content/repositories/releases/io/puharesource/osrs/eventsystem/1.0.1/eventsystem-1.0.1.jar Step #2 Now that we've added the system to our build path, it's time to setup the basic script skeleton a quick guide can be found here. I've gone ahead and removed the bits that we don't need for this tutorial. import org.osbot.rs07.script.Script; import org.osbot.rs07.script.ScriptManifest; @ScriptManifest(version = 1, author = "Puharesource", logo = "", name = "TestScript", info = "Showing you how to use the events system in a script.") public final class TestScript extends Script { @Override public void onStart() throws InterruptedException { //TODO: Add code that'll add our upcoming custom events to the event system. //TODO: Add code that'll add our upcoming listeners to the event system. } @Override public int onLoop() throws InterruptedException { //TODO: Add code that'll make the our upcoming custom events fire. return random(200, 300); } } Step #3 Now that we have the script skeleton, we're going to make our first event. This event will fire whenever a random number between 0 and 10 hits 5 and then take the System.currentTimeMillis() of when that happened. This event will also implement the CancellableEvent interface which means that we're going to be able to cancel the event and therefor stop certain subscribers from listening for the event (if cancelled). The event looks as follows: import io.puharesource.osrs.eventsystem.CancellableEvent; import io.puharesource.osrs.eventsystem.Event; public final class TestEvent extends Event implements CancellableEvent { private final long time; private boolean cancelled; public TestEvent() { this.time = System.currentTimeMillis(); } public long getTime() { return time; } @Override public boolean isCancelled() { return cancelled; } @Override public void setCancelled(boolean cancel) { this.cancelled = cancel; } } Step #4 Now that we've created our event, we have to register the event. This is done by adding the following to the onStart() method in our script class. @Override public void onStart() throws InterruptedException { EventManager.get().registerEvent(TestEvent.class); //TODO: Add code that'll add our upcoming listeners to the event system. } Step #5 Now that we've registered our event, we have to make it fire the event somehow. Again, in our test case, we'll be checking if a random number hits 5, if it does we're going to get the time and possibly run code to make it either cancel the event or go through. This is all done in our onLoop method in our script class. @Override public int onLoop() throws InterruptedException { if (random(0, 10) == 5) { final TestEvent event = new TestEvent(); EventManager.get().callEvent(event); if (!event.isCancelled()) { log("TestEvent cancelled!"); } } return random(200, 300); } As seen above, we get the number between 0 and 10 and check whether it's 5. If it is 5, we create a new instance of our event and call the event through the EventManager. Afterwards we check whether the event has been cancelled, if it has we're going to log that it was cancelled. Step #6 Now that we're able to fire the event, we'll need to create an EventListener with a few EventHandlers that will fire once the event is called. For a better understanding of the upcoming code, please read EventPriority and EventHandler import io.puharesource.osrs.eventsystem.EventHandler; import io.puharesource.osrs.eventsystem.EventListener; import io.puharesource.osrs.eventsystem.EventPriority; public final class TestListener implements EventListener { @EventHandler(priority = EventPriority.LOWEST) public void onEventFirst(final TestEvent event) { event.setCancelled(true); } @EventHandler public void onEventSecond(final TestEvent event) { if (event.isCancelled()) { event.setCancelled(false); } } @EventHandler(priority = EventPriority.HIGHEST) public void onEventLast(final TestEvent event) { if (event.getTime() % 2 != 0) { event.setCancelled(true); } } @EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR) public void onEventLog(final TestEvent event) { System.out.println("This event was fired at: " + event.getTime() + " and is an even number!"); } } As you can see, our class implements the EventListener interface. Our class also contains several methods of the same structure, with the @EventHandler annotation above them and our TestEvent as the methods ONLY parameter. Since our method onEventFirst, has the LOWEST priority, it will be executed before any of the other methods. (In this case we make it cancel the event) Then since our second event onEventSecond doesn't have ignoreCancelled = true in the EventHandler annotation, the code within it is still going to be executed, even though the event has been cancelled. (In this case we make it uncancel the event if the event is cancelled). Afterwards onEventLast will fire. (In this case we're if the time of which the event was fired, was an uneven number, if it was cancel it). And at last, we get to onEventLog which has the priority of MONITOR and ignores cancelled events. MONITOR events should ONLY be used for logging purposes and should not change any data. Since we cancelled the event in onEventLast if the time was an odd number, that means onEventLog will ONLY fire when the time was even. (This we obviously log). Step #7 At last, we just need to register our listener in our onStart() method in our script class. @Override public void onStart() throws InterruptedException { EventManager.get().registerEvent(TestEvent.class); EventManager.get().registerListener(new TestListener()); // Registered our listener. } And finally we're done. Remember, you can register as many events and listeners as you want. Simultaneously you can use as many EventListeners and EventHandlers for your events as you'd like.
  12. Using Multiple Classes Complete Guide! Tutorial Written By: @NotoriousPP Introduction: It has been brought to my attention that some script writers do not know how to use multiple class files inside of their project, and in this tutorial I will try to cover everything I can, to help you have a better understanding how this is done correctly. I will be working on an example project for this tutorial, just follow along using your own project, doesn’t matter which type of project, as long as you understand what’s going on. This project will be modeled in a State based framework, as I see this most often used throughout the forum. Another question you may have, why should you use multiple classes, what are the benefits, is there an upside? Speaking from an Organizational aspect, yes! Splitting up classes makes it easier for the writer and to whoever is working on the script, instead of having to search through a wall of text; you can simply find the class in your Project Folder. Things you’ll need: A Computer or Laptop. A IDE (For this tutorial I will be using Itellij) Latest Version of OSBot. A Brain (Might help) Getting your project setup: Create new project, and add OSBot as a library. Your project should now look something like this: Create packages inside of your src folder, this well help better organize your script! After doing this it should look similar to this: The Real Work Begins (Kinda): So now that we have packages in our src, we need to fill them up! So first lets create a Script class inside of our Core package. (Notice the Class name “ExampleScript”, this is following correct Conventions. An incorrect way of naming classes would be “examplescript”, “exampleScript”, “EXAMPLE_SCRIPT”, etc. If you would like to learn more about Conventions, you can go here: Code Conventions for the Java Programming Language) Alright so now we have a basic Skeleton setup, though it does nothing just yet. Well, lets change that! Since for this tutorial we are writing a State based script, first we need to create State Objects! To do this we need to create an Enum, which basically is “a special data type that enables for a variable to be a set of predefined constants.” (docs.oracle.com). I personally like to have a package that stores all my data needed for a script, so I’m going to create a new package “data”. After we have created the package, create a new Enum inside of the “data” package. (If you don’t know how to create an Enum right away, just create a new class file for right now, and I’ll show you what to do next!) (If you were one of the people who did not know how to create an Enum, simply create a new Class, and then replace “class” with “enum”, and your set!) For this Enum were are only really using the name, and not storing any real data here, so all we need to do is add the different States we want in our script! For this example, I will be using Attack, Eat, Loot, Drop, and Bank. REMEMBER! To follow correct Conventions we are going to name the states using all CAPITAL letters. Optional: Adding a toString() method can be used to make your “state” or “status” more presentable, and not YELLING AT YOU when displaying. The method essentially grabs whatever “state” being used, and modifies it to your liking. In the example below, it creates a final String “s”, then replaces all underscores (Not used in example) with a space; the next like I return the String “s”, though I grab the first Char of the string and add it to a substring for the rest of the string and add a toLowercase(), making ATTACK, to Attack. This is especially helpful when using States as a status; this method can be applied to all types of Enums! (Cool trick if you’re a Windows Intellij user! You can type all your states without having to type with caps lock, or holding shift; just type your states, select them, and press “ctrl + shift + u”, and it will capitalize all selected, or turn it to lowercase if already capital) So we have our States, now what do I do? Well we need to get a getState() method ready our Script class. If you don’t already know, this is the method we use to determine which action or “state” should be executed. Then in the onLoop we have a Switch statement that determines which action should be executed. So what do we do now? The some people here make the mistake of continuing using this class for their tasks, actions, and data; just everything really. This is exactly what this tutorials main focus is on; how we can use multiple classes to help organize our project. You Script class should now look something similar to this. So now we get to create our first separate class! You may ask, well how will I be able to use myPlayer(), client.getInventory(), if I’m not inside of the Script class. Well one word really “Constructors”. We are going to need to create a constructor that takes a Script variable which we can use throughout the script, in this case “sI” (Swizzbeat are you happy now? I didn’t use sA this time ) which refers to Script Instance; but first we need to create a new class inside of our “tasks” package (folder), and in the example I will be creating an Attack() class. In this class we create a public Constructor that accepts a Script variables “sI” as discussed before! So now you should have a class that looks like this. Well you’re almost done implementing your first separate class (If this is your first time that is)! In the Attack() class we can now use “sI” for all of the calls we need, so instead of typing myPlayer() like in the Script class, it would be sI.myPlayer() in your extended class. So for example you can do something along the line of this: (Please don’t use this snippit below for real, it’s just a funny example, I don’t want a PM saying this didn’t work…) Alright so I got a separate class, but how the hell do I use this shit? You might be asking. Well in your Script class, since you extended Script, by using “this” is other words a Script variable, so that’s what we will be using to call our class! So in the onLoop, we can now add the new separated class, simply by adding “new Attack(this);”. Yup it was that easy! So it should look similar to what I have below. Just import the class (Most IDEs do it automatically), and call the class using “new Class(this)”: Well if you don’t understand how this all works by now, read through it once more, it will make sense eventually! To add more classes to our project, just use the same logic we used in creating our Attack() class(Or hell you can just copy/paste, and edit a little). The other packages in our “src”, can be used for numerous of different classes, just it’s up to you to fill them, just use them to keep organized! Conculsion: Well if you followed along, and got it working correctly! Congratulations! Separating classes help you so much down the road when working with large project, teammates, and or co-workers! No one wants to read a wall of text, it’s much easier to navigate through folders and get the file you need (Like how an office files paper work, Duh…). I really hope you guys all enjoy reading this, and it helps a few people out with their scripts! If you have any suggestions, and or comments, please leave them below, and I’m more than gladly answer them! Also let me know about any errors that you find! I'm not a expert, just trying to help! Sources used: http://docs.oracle.com/javase/tutorial/java/javaOO/enum.html http://docs.oracle.com/javase/tutorial/java/javaOO/constructors.html http://www.oracle.com/technetwork/java/codeconv-138413.html
  13. I put this idea into effect a few months ago, where it slowly died out mainly due to the fact that most of the people who belonged to it have now quit/are MIA. Hopefully this time around it can become bigger (last time on some days I'd wake up to 1k+ messages from the group, just to give people an idea of how big it got) and there can be a place that scripters can go, besides the chat box, to get help with issues their having. I'd like this group to mainly focus on scripting, however it should also be a place where beginners and experienced Java programmers alike can learn a thing or two from their peers. Who knows, maybe some top notch scripting groups will be formed here If you'd like to join please send a message to OSSwizzbeat on Skype saying something along the lines of "please add me to the OSBot scripting chat". Don't take it personally if I don't accept your contact details, as I like to keep my contact list clean. MESSAGES SENT TO ME WITHOUT A REQUEST TO BE ADDED TO THE GROUP WILL BE IGNORED AS I WILL HAVE NO IDEA WHY YOU ARE ADDING ME
  14. Hello. I have made one script before, it was when I used the original RSBot from like 2007 or something, it just accepted duels in duel arena or something I can't even remember, can I get a short tutorial on how to pick up scripting? I know nothing.
  15. I have done some coding before but not from scratch... had some help. But I'd like to learn how to make scripts. If anyone would be willing to help me learn I would love you forever and i don't know it it costs but i'd pay :P
×
×
  • Create New...