• Log in or sign up for an account here: https://www.sythe.org/login

First Script Errors

Status
Not open for further replies.

Macroman

Hero
Do Not Trade
Joined
Jan 21, 2007
Sythe Gold
12
Messages
6,919
Location
Australia
First Script Errors
Illegal Start, Identifier expected etc. Try to compile it and read all the errors. This script is a first attempt at Walking from Varrock West Bank to The General store and buying 27 pots, then Returning to bank.

When you post a fix, please post why you changed something so I can remember it for future scripts.

Thanks
Errors are shown below.

Code:
[20:50:18][       Compiler] Compiling 41 class files using internal method.
[20:50:21][       Compiler] .\Scripts\WestBankToStore.java:19: illegal start of type
[20:50:21][       Compiler] .\Scripts\WestBankToStore.java:19: <identifier> expected
[20:50:21][       Compiler] .\Scripts\WestBankToStore.java:19: ';' expected
[20:50:21][       Compiler] .\Scripts\WestBankToStore.java:19: illegal start of type
[20:50:21][       Compiler] .\Scripts\WestBankToStore.java:21: invalid method declaration; return type required
[20:50:21][       Compiler] .\Scripts\WestBankToStore.java:23: illegal start of type
[20:50:21][       Compiler] .\Scripts\WestBankToStore.java:23: <identifier> expected
[20:50:21][       Compiler] .\Scripts\WestBankToStore.java:23: ';' expected
[20:50:21][       Compiler] .\Scripts\WestBankToStore.java:23: illegal start of type
[20:50:21][       Compiler] .\Scripts\WestBankToStore.java:26: illegal start of type
[20:50:21][       Compiler] .\Scripts\WestBankToStore.java:26: <identifier> expected
[20:50:21][       Compiler] .\Scripts\WestBankToStore.java:26: ';' expected
[20:50:21][       Compiler] .\Scripts\WestBankToStore.java:26: illegal start of type
[20:50:21][       Compiler] .\Scripts\WestBankToStore.java:26: <identifier> expected
[20:50:21][       Compiler] .\Scripts\WestBankToStore.java:26: ';' expected
[20:50:21][       Compiler] .\Scripts\WestBankToStore.java:27: illegal start of type
[20:50:21][       Compiler] .\Scripts\WestBankToStore.java:27: <identifier> expected
[20:50:21][       Compiler] .\Scripts\WestBankToStore.java:28: invalid method declaration; return type required
[20:50:21][       Compiler] .\Scripts\WestBankToStore.java:28: <identifier> expected
[20:50:21][       Compiler] .\Scripts\WestBankToStore.java:28: ';' expected
[20:50:21][       Compiler] .\Scripts\WestBankToStore.java:28: illegal start of type
[20:50:21][       Compiler] .\Scripts\WestBankToStore.java:28: <identifier> expected
[20:50:21][       Compiler] .\Scripts\WestBankToStore.java:28: ';' expected
[20:50:21][       Compiler] .\Scripts\WestBankToStore.java:28: illegal start of type
[20:50:21][       Compiler] .\Scripts\WestBankToStore.java:28: <identifier> expected
[20:50:21][       Compiler] .\Scripts\WestBankToStore.java:28: ';' expected
[20:50:21][       Compiler] .\Scripts\WestBankToStore.java:30: illegal start of type
[20:50:21][       Compiler] .\Scripts\WestBankToStore.java:30: <identifier> expected
[20:50:21][       Compiler] .\Scripts\WestBankToStore.java:30: ';' expected
[20:50:21][       Compiler] .\Scripts\WestBankToStore.java:30: illegal start of type
[20:50:21][       Compiler] .\Scripts\WestBankToStore.java:30: <identifier> expected
[20:50:21][       Compiler] .\Scripts\WestBankToStore.java:30: ';' expected
[20:50:21][       Compiler] .\Scripts\WestBankToStore.java:30: illegal start of type
[20:50:21][       Compiler] .\Scripts\WestBankToStore.java:80: illegal start of expression
[20:50:21][       Compiler] .\Scripts\WestBankToStore.java:83: illegal start of expression
[20:50:21][       Compiler] .\Scripts\WestBankToStore.java:83: ';' expected
[20:50:21][       Compiler] .\Scripts\WestBankToStore.java:83: ';' expected
[20:50:21][       Compiler] .\Scripts\WestBankToStore.java:92: illegal start of expression
[20:50:21][       Compiler] .\Scripts\WestBankToStore.java:92: ';' expected
[20:50:21][       Compiler] .\Scripts\WestBankToStore.java:95: reached end of file while parsing
[20:50:21][       Compiler] .\Scripts\WestBankToStore.java:98: reached end of file while parsing
[20:50:21][       Compiler] 41 error(s).









Code:
import java.awt.*;
import java.util.*;

import com.speljohan.rsbot.accessors.Player;
import com.speljohan.rsbot.bot.*;
import com.speljohan.rsbot.script.*;
import com.speljohan.rsbot.script.wrappers.*;


public class WestBankToStore extends Script{
      public String getName() {
          return "WestBankToStore";}






if (isInventoryFull( ))
     walkToBank();
 bankItems();

if(bankItems())
     walkToShop();

if (walkTopShop()){
     TradeSeller();
     wait(random(750, 1250));}

if ( interfaceExists(620) )
     buyItems();



















public RSTile[] toShop = new RSTile[]{
            new RSTile(3185, 3437),new RSTile(3201, 3428),new RSTile(3217, 3416)};
  

public RSTile[] toBank = new RSTile[]{  
          new RSTile(3214, 3423),new RSTile(3185, 3437)};





public boolean walktoShop( ){
        if ( distanceTo(toShop[toShop.length - 1]) < 5){
                return true;}
        else{
            walkPathMM(randomizePath(toShop,3,3), 15);
            return false;
                wait(3000);
        }
    }


public void TradeSeller( ){
        RSNPC ShopKeeper = getNearestNPCByID( 522,523 );{
            if ( ShopKeeper != null ){


atNPC(ShopKeeper, "Trade");
                wait( random(250, 500) );
                if ( interfaceExists(620) )}


public void Buyitems( ){
        clickMouse(76, 110, 3, 3, false );
        wait( random(10, 25) );
        atMenu("Buy X");
        wait(random(500, 1000));
        Bot.getInputManager().sendKeys("27", true);
        wait(random(750, 1250));
    }

public boolean bankitems(){
        RSObject bankBooth = findObject( 1142 );
        atObject(bankBooth, "Use-quickly");
        wait(random(750, 1000));
 
First Script Errors
Illegal Start, Identifier expected etc. Try to compile it and read all the errors. This script is a first attempt at Walking from Varrock West Bank to The General store and buying 27 pots, then Returning to bank.

When you post a fix, please post why you changed something so I can remember it for future scripts.

Thanks.

Please copy the errors in this topic, so I maybe can help;)
Also, put all the ifs in a function called loop:
Code:
public int loop() {
  if(... {
     dosomething();
     return 0;
  } else {
     return 1;
  }
Something like that, RSBot will call this function continuously.
 
First Script Errors
This is free of errors, but I do not think it will work... I have to go, I will tell you what you did wrong later... PS. CAPITALIZATION MATTERS!

Code:
import java.awt.*;
import java.util.*;

import com.speljohan.rsbot.accessors.Player;
import com.speljohan.rsbot.bot.*;
import com.speljohan.rsbot.script.*;
import com.speljohan.rsbot.script.wrappers.*;

public class WestBankToStore extends Script
{
	public String getName()
	{
		return "WestBankToStore";
	}

	public int loop()
	{

		if (isInventoryFull())
		{
			walkToBank();
			bankItems();
		}

		if (bankItems())
			walkToShop();

		if (walkToShop())
		{
			tradeSeller();
			wait(random(750, 1250));
		}

		if (interfaceExists(620))
			buyItems();
		
		return 1;
	}

	public RSTile[] toShop = new RSTile[]
	{ new RSTile(3185, 3437), new RSTile(3201, 3428), new RSTile(3217, 3416) };

	public RSTile[] toBank = new RSTile[]
	{ new RSTile(3214, 3423), new RSTile(3185, 3437) };

	public boolean walkToShop()
	{
		if (distanceTo(toShop[toShop.length - 1]) < 5)
		{
			return true;
		}
		else
		{
			walkPathMM(randomizePath(toShop, 3, 3), 15);
			wait(3000);
			return false;
		}
	}

	public boolean walkToBank()
	{
		if (distanceTo(toBank[toBank.length - 1]) < 5)
		{
			return true;
		}
		else
		{
			walkPathMM(randomizePath(toBank, 3, 3), 15);
			wait(3000);
			return false;

		}
	}

	public void tradeSeller()
	{
		RSNPC ShopKeeper = getNearestNPCByID(522, 523);
		if (ShopKeeper != null)
		{

			atNPC(ShopKeeper, "Trade");
			wait(random(250, 500));
		}
	}

	public void buyItems()
	{
		clickMouse(76, 110, 3, 3, false);
		wait(random(10, 25));
		atMenu("Buy X");
		wait(random(500, 1000));
		Bot.getInputManager().sendKeys("27", true);
		wait(random(750, 1250));
	}

	public boolean bankItems()
	{
		RSObject bankBooth = findObject(1142);
		atObject(bankBooth, "Use-quickly");
		wait(random(750, 1000));
		return true;
	}
}
 
First Script Errors
Code:
[22:09:33][WestBankToStore] Script started.
[22:09:33][WestBankToStore] java.lang.RuntimeException: You should implement private boolean onStart(Map<String, String> map) {
    at com.speljohan.rsbot.script.Script.onStart(Script.java:17)
    at com.speljohan.rsbot.script.Script.onStart(Script.java:30)
    at com.speljohan.rsbot.script.Script.run(Script.java:90)
    at com.speljohan.rsbot.script.ScriptHandler$1.run(ScriptHandler.java:70)
    at java.lang.Thread.run(Unknown Source)

[22:09:33][WestBankToStore] Failed to start up
 
First Script Errors
I recommend you use this template:
Code:
import java.awt.*;

import com.speljohan.rsbot.bot.Bot;
import com.speljohan.rsbot.event.listeners.PaintListener;
import com.speljohan.rsbot.script.Script;
import com.speljohan.rsbot.script.wrappers.*;

public class myfirstscript extends Script implements PaintListener { //change nothing but the script name (myfirstscript) here (filename must be the same as the script name liek myfirstscript.java)


	public void onRepaint(Graphics g) //function called to draw on the rs window
	{
		if (isLoggedIn()) {// check if logged in
				g.drawString("My very cool own script :)", 10, 30); 
		}
	}

	public double getVersion()
	{
		return 1.0; //must always return a double
	}

	public String getScriptCategory()
	{
		return "My scripts"; //must always return a string
	}

	public String getName()
	{
		return "my cool 1st script"; //must always return a string
	}

	public String getAuthor()
	{
		return "me :p"; //must always return a string
	}

	public boolean onStart(String[] args)
	{
		Bot.getEventManager().addListener(PaintListener.class, this); // << dont touch this
		log("script by me started.");
		return true; // << dont touch this
	}

	public void onFinish() {
		Bot.getEventManager().removeListener(PaintListener.class, this); //<< dont touch this
	}

	public int loop() {

		return 0; //loop must always return something!
	}

}
I commented it so you can understand things if it's all clear I also recommend you to rewrite the script in this template.:rolleyes:
 
First Script Errors
Thanks for the template basfreak, Also could someone else still help me on the other one.
 
First Script Errors
Thanks for the template basfreak, Also could someone else still help me on the other one.

Read your errors:
[22:09:33][WestBankToStore] Script started.
[22:09:33][WestBankToStore] java.lang.RuntimeException: You should implement private boolean onStart(Map<String, String> map) {
at com.speljohan.rsbot.script.Script.onStart(Script.java:17)
at com.speljohan.rsbot.script.Script.onStart(Script.java:30)
at com.speljohan.rsbot.script.Script.run(Script.java:90)
at com.speljohan.rsbot.script.ScriptHandler$1.run(ScriptHandler.java:70)
at java.lang.Thread.run(Unknown Source)

[22:09:33][WestBankToStore] Failed to start up
And then take a look at my template,
You should implement private boolean onStart(Map<String, String> map)
Your missing the onStart function.
 
First Script Errors
Ok.... I have time... Simple java lesson...

Code:
public class WestBankToStore extends Script
{
      public String getName() 
{
          return "WestBankToStore";
}






if (isInventoryFull( ))
     walkToBank();
 bankItems();

if(bankItems())
     walkToShop();

if (walkTopShop()){
     TradeSeller();
     wait(random(750, 1250));}

if ( interfaceExists(620) )
     buyItems();

see how those if statements are just surrounded by the class? Thats not allowed. All statements except for variable declaration must be in some sort of method... Basically...

The first if statement needs to be a block because it has more than 1 statement in it... You make a block with {}s...

Also, you must capitalize the method calls the same as you named them... And you were missing toBank or what ever you named that... You tried to use it and it was not in the file...

Code:
public void TradeSeller( ){
        RSNPC ShopKeeper = getNearestNPCByID( 522,523 );{
            if ( ShopKeeper != null ){


atNPC(ShopKeeper, "Trade");
                wait( random(250, 500) );
                if ( interfaceExists(620) )}

You can not have an if statement that does not do anything.. plus, you need more closing }'s... RSNPC does not need a opening {...

I suggest downloading eclipse... it will make finding syntax errors easier... .D:
 
First Script Errors
Also:
Code:
      public String getName() {
          return "WestBankToStore";}
That looks a bit messy better make it like:
Code:
      public String getName() {
          return "WestBankToStore";
      }
This will also help with finding errors.
 
First Script Errors
Haha, I think I'm getting there. Can someone fix up this script to a working order and post it. That would be really helpful, and Thank you so much everyone for the help.
 
First Script Errors
Haha, I think I'm getting there. Can someone fix up this script to a working order and post it. That would be really helpful, and Thank you so much everyone for the help.

If you try it yourself you'll learn more.
But what do you have now? Still the same as the first post?
 
First Script Errors
Haha, I think I'm getting there. Can someone fix up this script to a working order and post it. That would be really helpful, and Thank you so much everyone for the help.

Here.
Code:
import java.awt.*;
import java.util.*;

import com.speljohan.rsbot.accessors.Player;
import com.speljohan.rsbot.bot.*;
import com.speljohan.rsbot.script.*;
import com.speljohan.rsbot.script.wrappers.*;

public class WestBankToStore extends Script
{
	public RSTile[] toShopPATH = new RSTile[] { new RSTile(3185, 3437), new RSTile(3201, 3428), new RSTile(3217, 3416) };
	public RSTile[] toBankPATH = new RSTile[] { new RSTile(3214, 3423), new RSTile(3185, 3437) };

	RSTilePath toBank = new RSTilePath(randomizePath(toBankPATH,1,1), this);
	RSTilePath toShop = new RSTilePath(randomizePath(toShopPATH,1,1), this);

	public String getName()
	{
		return "WestBankToStore";
	}

	public String getAuthor()
	{
		return "Macroman";
	}

	public double getVersion()
	{
		return 1.0;
	}

	public String getScriptCategory()
	{
		return "My scripts";
	}

	public void onFinish()
	{
	}

	public int loop()
	{
		if (isInventoryFull())
		{
			walkToBank();
			bankItems();
		}

		if (bankItems())
			walkToShop();

		if (walkToShop())
		{
			tradeSeller();
			wait(random(750, 1250));
		}

		if (interfaceExists(620))
		{
			buyItems();
		}
		return 1;
	}

	public boolean onStart(String[] args)
	{
		return true;
	}


	public boolean walkToShop()
	{
		if (distanceTo(new RSTile(3217, 3416)) < 5)
		{
			return true;
		} else {
			try {
				toShop.walkToEnd();
			} catch (Exception e) {
			}
			wait(3000);
			return false;
		}
	}

	public boolean walkToBank()
	{
		if (distanceTo(new RSTile(3185, 3437)) < 5)
		{
			return true;
		} else {
			try {
				toBank.walkToEnd();
			} catch (Exception e) {
			}
			wait(3000);
			return false;

		}
	}

	public void tradeSeller()
	{
		RSNPC ShopKeeper = getNearestNPCByID(522, 523);
		if (ShopKeeper != null)
		{
			atNPC(ShopKeeper, "Trade");
			wait(random(250, 500));
		}
	}

	public void buyItems()
	{
		clickMouse(76, 110, 3, 3, false);
		wait(random(10, 25));
		atMenu("Buy X");
		wait(random(500, 1000));
		Bot.getInputManager().sendKeys("27", true);
		wait(random(750, 1250));
	}

	public boolean bankItems()
	{
		RSObject bankBooth = findObject(1142);
		atObject(bankBooth, "Use-quickly");
		wait(random(750, 1000));
		return true;
	}
}
 
First Script Errors
im glad your using randomized tiles now :)

the post above me looks sufficient so i will not try. :)

If u need help contact me on msn.. ill give u tutoring b/c ur leet.
 
Status
Not open for further replies.
Runescape Gamblingrunescape gambling
Back
Top