Welcome to TRiBot Forums

Register now to gain access to all of our features. Once registered and logged in, you will be able to contribute to this site by submitting your own content or replying to existing content. You'll be able to customize your profile, receive reputation points as a reward for submitting content, while also communicating with other members via your own private inbox, plus much more! This message will be removed once you have signed in.

Sign in to follow this  
Followers 0
Gustlik501

Need help with a buying script.

3 posts in this topic

I'm working on a script that buys death runes from aubury.

I've worked around all of the bugs i came across, but i keep getting 1 error i don't know how to fix.

The error appears at the line that says: boolean buy(int x){

package scripts;

import java.util.Random;

import org.tribot.api.input.Mouse;
import org.tribot.api.rs3.WebWalking;
import org.tribot.api2007.ChooseOption;
import org.tribot.api2007.Interfaces;
import org.tribot.api2007.Inventory;
import org.tribot.api2007.Objects;
import org.tribot.api2007.PathFinding;
import org.tribot.api2007.Player;
import org.tribot.api2007.types.RSItem;
import org.tribot.api2007.types.RSObject;
import org.tribot.api2007.types.RSTile;
import org.tribot.script.Script;
import org.tribot.script.ScriptManifest;

@ScriptManifest(authors = { "Gustlik501" }, category = "Mining", name = "GMiner")
public class DeathRunes extends Script {

	private final int[] Drop = { 440, 441 };

	private final int Shop_ID = 637;

	private final int Rune_ID = 560;

	private final RSTile[] SHOP_TILE = { new RSTile(3253, 3401, 0) };

	private boolean Start() {
		println("GMiner is now running.");
		return true;
	}

	public void run() {
		if (Start()) {
			while (true) {
				sleep(loop());
			}
		}

	}

	public RSObject findNearest(int distance, int... ids) {
		RSObject[] objects = Objects.findNearest(distance, ids);

		for (RSObject object : objects) {
			if (object != null) {
				return object;
			}
		}
		return null;
	}

	private int loop() {

		if (Inventory.isFull()) {
			Inventory.drop(Drop);
		} else {
			if (Player.getAnimation() == -1) {
				RSObject shop = findNearest(15, Shop_ID);
				if (shop != null) {
					if (shop.isOnScreen()) {
						if (Player.getAnimation() == -1) {
							Random number1 = new Random();
							int number2 = number1.nextInt(156 - 102 + 1) + 102;// Generates an average reaction time.
							sleep(number2);
							shop.click("Trade");
							boolean buy(int x){
							RSItem[] items = Interfaces.get(300, 75).getItems();
							for (int i = 0; i < items.length; i++) {
								if (items[i].getID() == 560) {
									println(items[i].getID()+ " "+ items[i].getStack());
									Mouse.click((int)items[i].getArea().getCenterX(), (int)items[i].getArea().getCenterY()+40,3);
								}
									if(x == 10){
										if(ChooseOption.isOptionValid("Buy 10")) {
											ChooseOption.select("Buy 10");
										}else{}
									}else{
											if(x == 5){
												if(ChooseOption.isOptionValid("Buy 10")) {
													ChooseOption.select("Buy 10");
													}else{}
											}else{
													if(x == 1){
														if(ChooseOption.isOptionValid("Buy 1")) {
															ChooseOption.select("Buy 1");
										}else{}
									}}}
								}
							}
						}
					}
				}
			}
		}
		return 21;
	}

}

 

Edited by Gustlik501

Share this post


Link to post
Share on other sites

No offence but learn java before trying to script, it'll save you lots of time. Your whole loop method's structure is terrible, but that isn't the worst part. If you're scripting you should know the basics of java, and not need to ask this much of an basic answer.

The problem is that you've just straight off copy-pasted a full method, with it's name and parameters, into another method. I suggest you to read/watch some java guides before continuing to script.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0

  • Recently Browsing   0 members

    No registered users viewing this page.