Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 03/09/14 in Posts

  1. Cat+Dog = Great Cartoon. So this is completely invalid.
    6 points
  2. 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
    4 points
  3. Congratulations to @whips for winning this SOTW!
    3 points
  4. - 09/03/2014 -10/03/2014 -11/03/2014 - 12/03/2014 - 13/03/2014 - 14/03/2014 - 15/03/2014 - 16/03/2014. - 17/03/2014 - 18/03/2014 - 19/03/2014 - 20/03/2014 - 21/03/2014 - 22/03/2014 - 23/03/2014 - 24/03/2014 - 25/03/2014 - 26/03/2014 -27/03/2014 - 28/03/2014 -29/03/2014 - 30/03/2014 -31/03/2014
    2 points
  5. I found this recently and thought I would share! It's just a giant collection of the source codes for the biggest scripts awhile back on clients like RSBuddy and p****bot, so obviously this code isn't written for OSBot but it's a great place to go to see how people did things and grab some snippets. Interestingly enough it also includes the source for iDungeon which was (I'm 99% sure) the most sold script ever. https://github.com/Stevemagegod/My-Favorite-Runescape-Scripts/tree/master/src
    2 points
  6. Can we ban hyphens and maybe periods too?
    2 points
  7. http://funnyvines.us/?id=1156
    2 points
  8. Send Raflesia a PM and apply for the rank.Stop going off-topic.
    2 points
  9. the videos are not helping :'(
    2 points
  10. Updated for OSBot 2's API! Hello future script writers and other OSBot members! This will be my first OSBot script writing tutorial, and it's geared toward beginners with at least some understanding of Java (however, I'll still be covering some fundamentals). So, let us begin. Step I: Getting the IDE An IDE (integrated development environment) is software that makes programming much easier on you, the programmer. There are many Java IDE's to choose from (IntelliJ, NetBeans, Eclipse, and many more), but for this tutorial, we'll be using Eclipse. You can download Eclipse here. Simply choose the Eclipse Standard and download the version for your computer (32 or 64 bit). Once downloaded, use a program to decompress the archive, and move the eclipse folder to wherever you'd like (C:\, your desktop, it honestly doesn't matter). To open Eclipse, go into that folder and open the Eclipse application. Congratulations, your one step closer to making OSBot scripts! Step II: Basic Java Fundamentals Java, like C++, PHP, and Javascript, is a high-level programming language, which simply means it's very readable by humans (we use English while programming in these languages) and therefore much simpler to write code. If you're an absolute beginner, with no background in programming at all, this is going to go by extremely fast, and I will likely skip over some important topics. If you fall into this category, you absolutely NEED to read these tutorials by Oracle. I'm not sure about most of you, but I feel that a great way to learn something is to dive right in, and worry about the little things after you've started to understand the bare essentials. With that in mind, let's take a look at a simple HelloWorld class: public class HelloWorld { public static void main(String[] args) { System.out.println("Hello World, I'm learning Java!"); } } Now looking at that might be intimidating if you're new to this, but believe me it's very simple! I'll break down some of the common words used above: public: This could be public, private, protected, or default. It simply states the visibility of this class/method/variable. Public items can be seen from outside of your package, private items can't be seen by other classes in your package, protected items can only be seen by the subclasses of your package, and default can only be seen by your package. class: A class is like a blueprint from which objects are created (Oracle). static: This is a keyword that simply means that only one instance of it will ever exist, even if you recreate it infinitely. void: This is the return type of this method. Void methods return nothing, int methods return integers, String methods return strings, and so on. String[]: This is an array. Arrays are just containers that hold a specific number of items (of one type). For example, this method takes an array of strings as a parameter. System.out.println: This is just a method that prints a message to the console and then prints the newline character. ;: Semi-colons are used at the end of any Java statement (note: conditionals and loops do not count as statements), without them, your compiler will give you errors. { }: These curly braces are used to surround/contain the contents of a class/method/etc. This is all of the Java basics I will teach, simply because there are already many resources out there (see above). Step III: Setting up a Java Project Setting up a Java project in Eclipse for making OSBot scripts is simple, just follow these steps: Step 1: Press File>New Java Project and name your project, then press finish Step 2: Add the OSBot .JAR file to your build path Step 3: Add a class to your new project And you're ready to actually start script writing! Step IV: Creating Your Script Now here's where we actually start making your script! For this example, we'll be creating a very simple mining script that will mine and drop everything once the inventory is full (please note: this example is hardly usable for a script, but it shows the basics. With a real mining script, you'll want to replace the object name with the ID(s) of the rocks, so you don't try mining empty veins). Here's the full source: import org.osbot.rs07.api.model.RS2Object; import org.osbot.rs07.script.Script; import org.osbot.rs07.script.ScriptManifest; import java.awt.*; @ScriptManifest(author = "You!", info = "I made this script!", name = "Basic Miner", version = 0, logo = "") public class BasicMiner extends Script { private enum State { MINE, DROP }; private State getState() { if (inventory.isFull()) return State.DROP; return State.MINE; } @Override public void onStart() { log("I can't believe script writing is this easy! I love learning!"); } @Override public int onLoop() throws InterruptedException { switch (getState()) { case MINE: if (!myPlayer().isAnimating()) { RS2Object vein = objects.closest("Rocks"); if (vein != null) { vein.interact("Mine"); } } break; case DROP: inventory.dropAll(); break; } return random(200, 300); } @Override public void onExit() { log("Thanks for using this wonderful script!"); } @Override public void onPaint(Graphics2D g) { } } Now most of that will be confusing, but don't worry, I'm here to help you! I'll break this down for you. import org.osbot.rs07.api.model.RS2Object; import org.osbot.rs07.script.Script; import org.osbot.rs07.script.ScriptManifest; import java.awt.*; These lines import other classes for their use in your script. @ScriptManifest(author = "You!", info = "I made this script!", name = "Basic Miner", version = 0, logo = "") This is the script manifest, which simply tells OSBot your script's author, info, name, and current version (for use in their class loader). public class BasicMiner extends Script { ... } This just defines our class, and extends OSBot's Script class, so we can use all of their fancy API methods. private enum State { MINE, DROP }; private State getState() { if (inventory.isFull()) return State.DROP; return State.MINE; } Here we make an enum (collection of constants) called State which holds two states: mine and drop. Then we have a method that's return type is State (so it returns a State, which we just made). If your inventory is full, this method will return the dropping state, otherwise it will return the mining state. @Override public void onStart() { log("I can't believe script writing is this easy! I love learning!"); } This method is part of OSBot's Script class (which we're extending from). The onStart() method is only called once, and is called at the beginning of the script. This is where you should define some variables that only need defined once (the start time, start experience/level, etc.). @Override public int onLoop() throws InterruptedException { switch (getState()) { case MINE: if (!myPlayer().isAnimating()) { RS2Object vein = objects.closest("Rocks"); if (vein != null) { vein.interact("Mine"); } } break; case DROP: inventory.dropAll(); break; } return random(200, 300); } This is another method from OSBot's Script class (see that @Override?). onLoop() returns an integer, or how many milliseconds to wait before doing onLoop() again. We then use a switch statement to see what we should be doing. If we're to mine, we check if our player is currently animating (mining). If we aren't, we find the closest rock to mine, if that doesn't exist (or is null), we stop right there. But if it isn't null, we interact with the rocks by pressing "Mine". If we're to drop, we simply drop everything in your inventory (you did have your pickaxe equipped, right?). @Override public void onExit() { log("Thanks for using this wonderful script!"); } @Override public void onPaint(Graphics2D g) { } onExit() and onPaint(Graphics g) are two more methods from the Script class. onExit() is called once your script is stopped, and onPaint(Graphics g) is called every time the screen is updated. Step V: Exporting Your Script The final step to this tutorial will be exporting the script we just made so we can actually test it out! Step 1. Right click your project and press Export... Step 2: Choose JAR file Step 3: Choose your OSBot's scripts directory and export it! Well that's all for this tutorial, thanks for reading! You can find Part II here! Also: post suggestions for future tutorials, and I'll definitely consider it!
    1 point
  11. How to Use Private/Secure Proxies ----------------------------------------------------------- ***There is a possibility that this does not utilize the proxy you put in credentials for. Please see mod Mikasa's post for more info I and a lot of people from what I've seen have been having difficulties running private/secure proxies with osbot. One of the few guides on here only shows how to use public proxies. Its actually very simple to get that code to work with private/secure proxies as well. This is the code and just replace the variables (IP,PORT,USER,PASSWORD) with your proxy IP, port, the username provided by the seller, and the password provided by the seller. Open up notepad and be sure to save the code under all types, instead of text document. Then save it as "anything.bat", it can be called whatever as long as you have it as .bat Place this .bat into a folder along with the osbot client and rename the client to "osbot" To run the client through the proxy just use the .bat file If you want to run multiple proxies repeat this process but with separate folders, and each bot will have to be run in its own client. Simplified steps will be below the code @echo off "C:\Program Files (x86)\Java\jre7\bin\java.exe" -Dsocks.proxyHost=IP -Dsocks.proxyPort=PORT -Dhttp.proxyUser=USER -Dhttp.proxyPass=PASSWORD -jar -Xmx256m osbot.jar pause SIMPLIFIED ----------------------------- 1. Create a folder 2. Create a text document in the folder 3. Put the above code in the text document 4. Put in your proxy info 5. Save it as all types and as a .bat file 6. Put the osbot client into the folder 7. Rename the osbot client to "osbot" 8. Use the .bat file to run the client through the proxy ----------------------------- KNOWN ISSUES ----------------------------- 1. When renaming the client to "osbot" and that does not work, try renaming it to "osbot.jar" as some computers recognize the extensions by default and others do not. ----------------------------- This is my first ever guide of any sort, let me know if you have any problems following it and I will make changes accordingly and will update the known issues list as people report problems/fixes for those problems. I did not create the code on my own, it was taken from the help of smoke420 and some other users, I only compiled it into a guide for everyone to see and use. Happy botting
    1 point
  12. You might want to go beyond Enum cases and explain other frameworks as well. Nodes are good for beginners too.
    1 point
  13. Thank you for this mate, quite helpful
    1 point
  14. It's like the first password I've ever used on RS, so I guess that's a new rule?
    1 point
  15. LOL not true. I wrote a few scripts for RSBot back in the day and they were all packaged.
    1 point
  16. 1 point
  17. Nah man I know where you're coming from BUT ITS NOT MY BUTT CRACK ITS THE ACTUAL ANUS GLANDS THAT ITCH!
    1 point
  18. I would say they've all done a smashing job
    1 point
  19. Guys did your hear about this new AWESOME GLITCH Runescape.com/forums/topic-2424542 its gyazo dont worry
    1 point
  20. It's mark why not trust it .
    1 point
  21. Actually I have not complained about any scripts except for two of yours because you make a halfass script, release it and dont answer people telling you errors thats going wrong with your script, go look at your Skeleton slayer script I posted like 4 days ago or more on it and no answer from you explaining the reason for the error
    1 point
  22. I use my sock, thanks for the tissue idea.
    1 point
  23. lol this is just so wrong Please calc the odds of these 2 accounts: ( I wasn't able to follow your formula ) Player 1: 99 Att, 1 Str, 1 Def, 60 hp Player2: 1 Att, 99 Str, 1 Def, 60 hp
    1 point
  24. 1) No. Is this really needed? Like, it's rather pathetic if you NEED to discuss porn with other people. 2) I'd say yes, since OSBot 2 is far from done, and we're stuggling working with what we have now. 3) No, this isn't a popularity contest. 4) No, this is situational of course. 5) In that case, the private servers are paid advertisement, which is why they're being posted by an admin. Just like how there are paid ad banners on the forums + client. 6) Situational again, but the rules can be handled however the mod sees fit, to an extent. Also, u wot m8
    1 point
  25. 1 point
×
×
  • Create New...