Jump to content
View in the app

A better way to browse. Learn more.

OSBot :: 2007 OSRS Botting

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

GE Script Question

Featured Replies

Hello everyone!
 

I am currently having issues using values that were determined in a previous case.

 

So what's happening is I have two cases, Case A and Case B.

 

In Case A I've declared the following

long BuyPriceNew = grandExchange.getAmountSpent(Box.BOX_1);

Which Logs the amount spent in the GE box into the Long "BuyPriceNew"

 

However when I go into Case B and try to call upon BuyPriceNew I get the following error.

 

 
The local variable BuyPriceNew may not have been initialized. Note that a problem regarding missing 'default:' on 'switch' has been suppressed, which is perhaps related to this problem main.java /XMerch/src line 136 Java Problem

What am I doing wrong? 
 

 

You have to initialise your variable before the switch statement with an actual value.

long buyPriceNew = 0;

switch (...) {
case A:
    buyPriceNew = grandExchange.getAmountSpent(Box.BOX_1);
    return;
case B:
    ... // the variable is initialised here so you can use it
}

Use null as a default value for all types except for numerical ones.

  • Author

Thanks man!

 

A second question...I want my script to perform a profit check function first and then move on to repeating the merch function until a certain time. My issue is that I cannot even get it to move from the ProfitCheck Case to the Merch Case

 

Here is my Code

    	NPC clerk = npcs.closest("Grand Exchange Clerk");
    	if (clerk !=null && grandExchange.isOpen() == false)
    		return State.ExchangeBanker;
    		int OpenedIt = 1;
    		int CheckedIt = 0;
    	if (OpenedIt <= 2 && CheckedIt == 0)
    		return State.ProfitCheck;
    		OpenedIt += 1;
    		CheckedIt += 1;
    	if(CheckedIt >= 0)
    		return State.MerchTime;
    	return State.Wait;
    	}

Here you see that I'm simply trying to get the script to recognize that if the previous case was completed it can move onto the next case, but for some reason it keeps hanging on the profit check case.

Thanks man!

 

A second question...I want my script to perform a profit check function first and then move on to repeating the merch function until a certain time. My issue is that I cannot even get it to move from the ProfitCheck Case to the Merch Case

 

Here is my Code

    	NPC clerk = npcs.closest("Grand Exchange Clerk");
    	if (clerk !=null && grandExchange.isOpen() == false)
    		return State.ExchangeBanker;
    		int OpenedIt = 1;
    		int CheckedIt = 0;
    	if (OpenedIt <= 2 && CheckedIt == 0)
    		return State.ProfitCheck;
    		OpenedIt += 1;
    		CheckedIt += 1;
    	if(CheckedIt >= 0)
    		return State.MerchTime;
    	return State.Wait;
    	}

Here you see that I'm simply trying to get the script to recognize that if the previous case was completed it can move onto the next case, but for some reason it keeps hanging on the profit check case.

 

The code where you increment OpenedIt and CheckedIt is unreachable

 

also camelCase pls

 

also you probably want to learn Java before writing a massive merch script

Thanks man!

 

A second question...I want my script to perform a profit check function first and then move on to repeating the merch function until a certain time. My issue is that I cannot even get it to move from the ProfitCheck Case to the Merch Case

 

Here is my Code

    	NPC clerk = npcs.closest("Grand Exchange Clerk");
    	if (clerk !=null && grandExchange.isOpen() == false)
    		return State.ExchangeBanker;
    		int OpenedIt = 1;
    		int CheckedIt = 0;
    	if (OpenedIt <= 2 && CheckedIt == 0)
    		return State.ProfitCheck;
    		OpenedIt += 1;
    		CheckedIt += 1;
    	if(CheckedIt >= 0)
    		return State.MerchTime;
    	return State.Wait;
    	}

Here you see that I'm simply trying to get the script to recognize that if the previous case was completed it can move onto the next case, but for some reason it keeps hanging on the profit check case.

 

No code after a return statement will be executed. 

  • Author

Awesome!

Thanks for the help guys. I have problems learning java by just reading "How to Java", I do a lot better learning it when I actually type it and do trial and error. 

Create an account or sign in to comment

Recently Browsing 0

  • No registered users viewing this page.

Account

Navigation

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.