Jump to content


  • Content count

  • Joined

  • Last visited

  • Feedback


Community Reputation

20 Excellent

About VBsec

  • Rank
    Senior Botter

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

  1. VBsec

    Basic Antiban

    You've got a few references to CTMiner..so it won't even compile for anyone else. Other things I have in mind have already been said above.
  2. VBsec

    I/O Utility

  3. VBsec

    Bot ignoring randoms after latest RS update

    It's perfectly normal, no need to get worried.
  4. VBsec

    Script templates

    Quite so, yet if all code is in one class it doesn't make much of a difference.
  5. VBsec

    Script templates

    I read it in a book a while ago but it's true, it does go between private and protected, though the line between default and protected is very thin. The comment works as a reminder for beginners, the real learning isn't going to happen with a template.
  6. VBsec

    I/O Utility

    /* * IOUtility.java 04/04/2014 * * VBsec */ package scripts.generalUtils; import java.awt.Desktop; import java.awt.image.BufferedImage; import java.io.File; import java.io.FileOutputStream; import java.io.FileReader; import java.io.FileWriter; import java.io.FilenameFilter; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.io.Reader; import java.io.Writer; import java.net.URL; import java.nio.charset.Charset; import java.nio.file.Files; import java.nio.file.Paths; import java.util.ArrayList; import java.util.Collections; import java.util.List; import javax.imageio.ImageIO; import org.tribot.api.General; public class IOUtility { private static final String TXT = ".txt"; /* * @param path = The path for saving the file to. e.g. new File(Util.getWorkingDirectory() + "\\Yourname-scripts\\YourScript") * @param name = The name of the file to be saved. * @param contents = The string you want to save. */ public static void saveTextFile(File path, String name, String contents) throws IOException { if (!path.exists()) path.mkdirs(); try (Writer output = new FileWriter(new File(path + "\\" + name + TXT)) { output.write(contents); } } /* * @param path = The path for saving the file to. * @param name = The name of the file to be saved. * @param contents = The string array you want to save. */ public static void saveTextFile(File path, String name, String[] contents) throws IOException { if (!path.exists()) path.mkdirs(); try (Writer output = new FileWriter(new File(path + "\\" + name + TXT)) { for (String line : contents) output.write(line + System.lineSeparator()); } } /* * @param path = The path that contains the file. * @param name = The name of the file to be read. * * Maximum length is 256 characters. Can be adjusted by changing the char array size. */ public static String readTextFile(File path, String name) throws Exception { if (!path.exists() || path.listFiles().length == 0) return null; try (Reader input = new FileReader(new File(path + "\\" + name + TXT)) { char[] chars = new char[256]; while (input.read(chars) != -1) ; String contents = String.valueOf(chars); return contents.trim(); } } /* * @param path = The path that contains the file. * @param name = The name of the file to be read. */ public static String[] readTextFileIntoArray(File path, final String fileName) throws Exception { String[] contents; if (!path.exists() || path.list(new FilenameFilter() { @Override public boolean accept(File dir, String name) { return name.contains(fileName); } }).length == 0) return null; List<String> lines = Files.readAllLines( Paths.get(path.getAbsolutePath() + "\\" + fileName + TXT), Charset.forName("UTF-8")); contents = new String[lines.size()]; return lines.toArray(contents); } /* * @param urlString = The URL to open. e.g. "http://tribot.org" */ public static void openWebpage(String urlString) { try { if (Desktop.isDesktopSupported()) { Desktop.getDesktop().browse(new URL(urlString).toURI()); } else { Runtime runtime = Runtime.getRuntime(); runtime.exec("/usr/bin/firefox -new-window " + urlString); } } catch (Exception e) { General.println("Couldn't open the link to " + urlString + System.lineSeparator() + e.getMessage()); } } /* * @param path = The path to the images e.g. Util.getWorkingDirectory() + "\\Yourname-scripts\\YourScript" * @param names = An array containing the names of the images. Include the extension. e.g. { "mainPaint.png", "closeButton.png" } * * Store the returned array in a variable in the class you call the method from. e.g. BufferedImage[] images = IOUtility.readImages(path, names); */ public static BufferedImage[] readImages(String path, String[] names) { BufferedImage[] imageArray = new BufferedImage[names.length]; try { for (int i = 0; i < names.length; i++) { File imagePath = new File(path + "\\" + names); if (imagePath.exists()) imageArray = ImageIO.read(imagePath); else { General.println("Couldn't find image " + names); return imageArray; } } } catch (IOException e) { General.println("Couldn't find images." + System.lineSeparator() + e.getMessage()); return null; } return imageArray; } // utility method for downloadImages() private static boolean findImages(File path, String[] names) { File[] files = path.listFiles(); ArrayList<String> fileList = new ArrayList<>(); ArrayList<String> nameList = new ArrayList<>(); for (File f : files) fileList.add(f.getName()); Collections.addAll(nameList, names); return fileList.containsAll(nameList); } /* * @param path = The path to save the images to. * @param picNames = An array containing names that will be used when saving to file. Include the extension. e.g. { "mainPaint.png", "closeButton.png" } * @param links = An array of links for the images. The order must be the same as in the picNames array. e.g. {"http://www.tinypic.com/mainPaint.png", * "http://www.tinypic.com/closeButton.png" } */ public static boolean downloadImages(File path, String[] picNames, String[] links) throws IOException { if (!path.exists()) { path.mkdirs(); } else if (findImages(path, picNames)) return true; for (int i = 0; i < links.length; i++) { URL website = new URL(links); File file = new File(path + "\\" + picNames); try (InputStream input = website.openStream(); OutputStream output = new FileOutputStream(file) { int c; while ((c = input.read()) != -1) output.write(c); } } return false; } }
  7. VBsec

    Script templates

    Makes sense. I also appreciate the way you present your point of view. So I changed them. Node to Jobexecute() to work()validate() to isIncomplete()If a job is incomplete you've gotta go to work. Now there shouldn't be any misunderstandings.
  8. VBsec

    Script templates

    The raw version hasn't got access modifiers or proper names because it's plain and simple and won't be used by anyone who's going to write thousands of lines of code per script. The plainer it is, the easier it is to use. Plus it's not particularly educational, just a template. And Druid, would you mind elaborating why the structure is bad and pointless? It's worked quite nicely for me and I've grown fond of it.
  9. VBsec

    Script templates

    When I first introduced myself to nodes I was delighted. It was a very clear system and the naming wasn't a problem for me. I'm not particularly sensitive about it. The main point is, after all, if something is validated, it gets executed.
  10. VBsec

    Script templates

    I suppose it might be a bit misleading but that's the name that was given to them, I didn't choose it. Do you have a suggestion for a better name?
  11. VBsec

    Script templates

    Template #1 - Raw Simple and beginner-friendly. Difficulty: Very Easy Instructions: Make a new class in your project and paste what's below there. The name can be changed (in Eclipse click the name and press Alt+Shift+R, type the new name and press enter). package scripts;import java.awt.Graphics;import java.awt.Graphics2D;import org.tribot.api2007.types.RSNPC;import org.tribot.script.Script;import org.tribot.script.ScriptManifest;import org.tribot.script.interfaces.Painting;@ScriptManifest(authors = { "author" }, category = "category", name = "name")public class EasyTemplate extends Script implements Painting { /* Instance variables. Can be used anywhere in the class. The access modifier (public, protected, private) is default if you leave it out.It lands between private and protected and is visible to the package this class is in. */ int someInt; long someLong; String someString; RSNPC someNPC; boolean running = true; @Override public void onPaint(Graphics g) { Graphics2D g2 = (Graphics2D) g; //Cast the Graphics object to a more specific type to get more methods. } @Override public void run() { //runs while running is true. Repeats the loop() method and sleeps for whatever gets returned at each iteration. while (running) { sleep(loop()); } } int loop() { doStuff(); return 1000; } void doStuff(){ // doing stuff.. }}Template #2 - Jobs Multiple classes and packages. Plan and organize. Difficulty: Intermediate Instructions: Unzip to .tribot/src/scripts and refresh your IDE project, assuming your project's folder is indeed the aforementioned. Template.zip
  12. This easily used snippet allows you to reorganize the top row of your inventory. In a script that involves a lot of dropping, it's handy to have a failsafe in case the user doesn't realize he's supposed to have all of the things the script requires in the first 4 slots. private static Point TOP_1_KEEP = new Point(578, 228), TOP_2_KEEP = new Point(622, 228), TOP_3_KEEP = new Point(666, 228), TOP_4_KEEP = new Point(706, 228);public static boolean moveItemsUp(int[] itemIDs) { RSItem[] items = Inventory.find(itemIDs); if (items.length > 4) { General.println("Too many items."); return false; } for (RSItem item : items) { if (item.getArea().getCenterY() > 235) { item.hover(); Point newPoint = getNewPoint(Inventory.find(itemIDs)); if (newPoint == null) return true; General.sleep(100); Mouse.drag(Mouse.getPos(), newPoint, 1); General.sleep(150); } } for(RSItem item : Inventory.find(itemIDs)){ if (item.getArea().getCenterY() > 235) return false; } return true; } private static Point getNewPoint(RSItem[] items) { Point[] points = { TOP_1_KEEP, TOP_2_KEEP, TOP_3_KEEP, TOP_4_KEEP }; Point[] itemPoints = new Point[items.length]; int i = 0; for (RSItem item : items) { itemPoints[i] = new Point( (int) item.getArea().getCenterX(), (int) item .getArea().getCenterY()); i++; } loop: for (Point point : points) { for (Point itemPoint : itemPoints) { if (point.distance(itemPoint) < 20) continue loop; if (itemPoint.equals(itemPoints[itemPoints.length - 1]) && point.equals(points[3]) && point.distance(itemPoint) < 20) break loop; } return point; } return null; }Example of use: int[] itemsToMove = { 23, 34, 44, 224 };if(moveItemsUp(itemsToMove)) doStuff(); //success!!else General.println("Failed");
  13. VBsec

    Magic class upgrade

    Magic.getAutocastSpell() could be beneficial too.
  14. VBsec

    [WARNING] Turn off Auto Responder!

    Never used it, never will. It's quite analogous to real world; when you don't know what to say, keep your mouth shut.
  15. Since it's running alongside another script I'd rather not interfere in any way. It's possible to implement this but can cause more problems than do good.