Search the Community
Showing results for tags 'Advanced'.
-
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!
- 5 replies
-
- Beginner
- Intermediate
-
(and 1 more)
Tagged with:
-
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?
- 1 reply
-
- Beginner
- Intermediate
-
(and 1 more)
Tagged with:
-
Title pretty much says it all. Character needs to sleep, when combining items. Character doesn't do an animation. Some sort of inventory listener?
- 8 replies
-
- Beginner
- Intermediate
-
(and 1 more)
Tagged with:
-
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!
- 6 replies
-
- Beginner
- Intermediate
-
(and 1 more)
Tagged with:
-
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
- 4 replies
-
- Beginner
- Intermediate
-
(and 1 more)
Tagged with:
-
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); } }
- 2 replies
-
- Beginner
- Intermediate
-
(and 1 more)
Tagged with:
-
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?
- 12 replies
-
- Beginner
- Intermediate
-
(and 1 more)
Tagged with:
-
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.
- 8 replies
-
- Beginner
- Intermediate
-
(and 1 more)
Tagged with:
-
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){} }
- 5 replies
-
- 1
-
- Beginner
- Intermediate
-
(and 1 more)
Tagged with:
-
Yo what do I return in onLoop when i want to stop the script? I tried returning -1 but that just crashed osbot.
- 3 replies
-
- Beginner
- Intermediate
-
(and 1 more)
Tagged with:
-
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
- 19 replies
-
- 12
-
- Beginner
- Intermediate
-
(and 1 more)
Tagged with:
-
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
- 28 replies
-
- 1
-
- Beginner
- Intermediate
-
(and 1 more)
Tagged with:
-
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.
- 2 replies
-
- Beginner
- Intermediate
-
(and 1 more)
Tagged with: