First Script Errors

Discussion in 'Archives' started by Macroman, Feb 20, 2009.

Thread Status:
Not open for further replies.
First Script Errors
  1. Unread #1 - Feb 20, 2009 at 3:10 AM
  2. Macroman
    Joined:
    Jan 21, 2007
    Posts:
    6,919
    Referrals:
    9
    Sythe Gold:
    12

    Macroman Hero
    Do Not Trade

    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));
     
  3. Unread #2 - Feb 20, 2009 at 3:51 AM
  4. basfreak
    Joined:
    Apr 26, 2007
    Posts:
    14
    Referrals:
    0
    Sythe Gold:
    0

    basfreak Newcomer

    First Script Errors

    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.
     
  5. Unread #3 - Feb 20, 2009 at 5:56 AM
  6. Macroman
    Joined:
    Jan 21, 2007
    Posts:
    6,919
    Referrals:
    9
    Sythe Gold:
    12

    Macroman Hero
    Do Not Trade

    First Script Errors

    Updated original post and added errors.
    41 Errors.
     
  7. Unread #4 - Feb 20, 2009 at 6:38 AM
  8. SuF
    Joined:
    Jan 21, 2007
    Posts:
    14,212
    Referrals:
    28
    Sythe Gold:
    1,234
    Discord Unique ID:
    203283096668340224
    <3 n4n0 Two Factor Authentication User Community Participant Spam Forum Participant Sythe's 10th Anniversary

    SuF Legend
    Pirate Retired Global Moderator

    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;
    	}
    }
     
  9. Unread #5 - Feb 20, 2009 at 7:10 AM
  10. Macroman
    Joined:
    Jan 21, 2007
    Posts:
    6,919
    Referrals:
    9
    Sythe Gold:
    12

    Macroman Hero
    Do Not Trade

    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
    
     
  11. Unread #6 - Feb 20, 2009 at 7:40 AM
  12. basfreak
    Joined:
    Apr 26, 2007
    Posts:
    14
    Referrals:
    0
    Sythe Gold:
    0

    basfreak Newcomer

    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:
     
  13. Unread #7 - Feb 20, 2009 at 7:44 AM
  14. Macroman
    Joined:
    Jan 21, 2007
    Posts:
    6,919
    Referrals:
    9
    Sythe Gold:
    12

    Macroman Hero
    Do Not Trade

    First Script Errors

    Thanks for the template basfreak, Also could someone else still help me on the other one.
     
  15. Unread #8 - Feb 20, 2009 at 7:59 AM
  16. basfreak
    Joined:
    Apr 26, 2007
    Posts:
    14
    Referrals:
    0
    Sythe Gold:
    0

    basfreak Newcomer

    First Script Errors

    Read your errors:
    And then take a look at my template,
    Your missing the onStart function.
     
  17. Unread #9 - Feb 20, 2009 at 8:23 AM
  18. Macroman
    Joined:
    Jan 21, 2007
    Posts:
    6,919
    Referrals:
    9
    Sythe Gold:
    12

    Macroman Hero
    Do Not Trade

    First Script Errors

    This may come as a tragedy to you, but I have absolutely no idea what to fix, and how.
     
  19. Unread #10 - Feb 20, 2009 at 8:31 AM
  20. SuF
    Joined:
    Jan 21, 2007
    Posts:
    14,212
    Referrals:
    28
    Sythe Gold:
    1,234
    Discord Unique ID:
    203283096668340224
    <3 n4n0 Two Factor Authentication User Community Participant Spam Forum Participant Sythe's 10th Anniversary

    SuF Legend
    Pirate Retired Global Moderator

    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:
     
  21. Unread #11 - Feb 20, 2009 at 8:38 AM
  22. basfreak
    Joined:
    Apr 26, 2007
    Posts:
    14
    Referrals:
    0
    Sythe Gold:
    0

    basfreak Newcomer

    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.
     
  23. Unread #12 - Feb 20, 2009 at 9:01 AM
  24. Macroman
    Joined:
    Jan 21, 2007
    Posts:
    6,919
    Referrals:
    9
    Sythe Gold:
    12

    Macroman Hero
    Do Not Trade

    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.
     
  25. Unread #13 - Feb 20, 2009 at 9:10 AM
  26. basfreak
    Joined:
    Apr 26, 2007
    Posts:
    14
    Referrals:
    0
    Sythe Gold:
    0

    basfreak Newcomer

    First Script Errors

    If you try it yourself you'll learn more.
    But what do you have now? Still the same as the first post?
     
  27. Unread #14 - Feb 23, 2009 at 10:07 AM
  28. Jimmy
    Joined:
    Jun 24, 2008
    Posts:
    2,421
    Referrals:
    10
    Sythe Gold:
    25

    Jimmy Ghost
    Retired Sectional Moderator $5 USD Donor

    First Script Errors

    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;
    	}
    }
     
  29. Unread #15 - Feb 23, 2009 at 5:10 PM
  30. draggin pure
    Joined:
    Apr 7, 2008
    Posts:
    1,429
    Referrals:
    0
    Sythe Gold:
    0

    draggin pure Guru
    Banned

    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.
     
< [PayPal][Rsgp]Spiderman's Pure account shop! | Selling Great Lv 54 Pure, 70 Mage, Dt Done, 70 Range! Worth Looking at!! (Ebay -) >

Users viewing this thread
1 guest
Thread Status:
Not open for further replies.


 
 
Adblock breaks this site