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.

explanation onStart()

Featured Replies

can someone explain to me this \/

catch try {...................} 
catch (interruptedException e)
// TODO Auto-generated catch block
e.printStackTrace(); 
}

im trying to create a farming script, and on the onStart() i want it to do more then one action. But i don't fully understand the (catch............). do i only need one (Catch..........), or more then one, if my onStart() has more then one action.

public void onStart(){
if (client.getInventory().contains(ectophial)
&& !EctoArea.contains(myPlayer())){
try {
this.client.getInventory().interactWithId(ectophial, "Empty");
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
if (myPlayer().getAnimation()== 714) {
while(myPlayer().getAnimation()== 714) {
try {
sleep(1000);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
state = State.WALKTOECTOHERB;
}
}
}

 

 

Edited by josedpay

 

do i only need one (Catch..........), or more then one, if my onStart() has more then one action.

 

You don't necessarily need it at all.

 

 

Also, This

!EctoArea.contains(myPlayer())

Should be this

!client.getMyPlayer().isInArea(EctoArea))

Dont catch the exception, you should throw it, so in the method signature throw InterruptedException

 

so it would be like

public void onStart() throws InterruptedException {

and remove the try and catch block.

  • Author

so it should look something like this then 

	public void onStart() throws InterruptedException {
		if (client.getInventory().contains(ectophial)
			&&!client.getMyPlayer().isInArea(EctoArea))	{
			client.getInventory().interactWithId(ectophial, "Empty");
				if (myPlayer().getAnimation()== 714)	{
					while (myPlayer().getAnimation()== 714)	{
							sleep(1000);
					}
				}
			state = State.WALKTOECTOHERB;
			}
		}

 i try this out then Eclipse is having a sissy fit, it say you remove the exception.

 

Edited by josedpay

What the error? when you hover over the red line what does it say?

 

EDIT: nvm remove the throw thing, the onStart method in the Scrip class doesnt throw InterruptedException, I think you have to add the try and catch blocks again

 

And what is try and catch basically is a code that try to preform the code between the try {} and if something unexcepted happened it catches the errors.

Edited by Mithrandir

 

You don't necessarily need it at all.

 

 

Also, This

!EctoArea.contains(myPlayer())

Should be this

!client.getMyPlayer().isInArea(EctoArea))

 

Easier to do !myPlayer().isinArea(EctoArea)) biggrin.png

 

OT - Just throw InterruptedException

 

 

  • Author

What the error? when you hover over the red line what does it say?

 

EDIT: nvm remove the throw thing, the onStart method in the Scrip class doesnt throw InterruptedException, I think you have to add the try and catch blocks again

 

And what is try and catch basically is a code that try to preform the code between the try {} and if something unexcepted happened it catches the errors.

	public void onStart() {
		if (client.getInventory().contains(ectophial)
			&&!myPlayer().isInArea(EctoArea))	{
			try {
				client.getInventory().interactWithId(ectophial, "Empty");
			} catch (InterruptedException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
				if (myPlayer().getAnimation()== 714)	{
					while (myPlayer().getAnimation()== 714)	{
							try {
								sleep(1000);
							} catch (InterruptedException e) {
								// TODO Auto-generated catch block
								e.printStackTrace();
							}
					}
				}
			state = State.WALKTOECTOHERB;
			}
		}

so then this (what i had in the beginning, with just a little tweaks wink.png )

	public void onStart() {
		if (client.getInventory().contains(ectophial)
			&&!myPlayer().isInArea(EctoArea))	{
			try {
				client.getInventory().interactWithId(ectophial, "Empty");
			} catch (InterruptedException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
				if (myPlayer().getAnimation()== 714)	{
					while (myPlayer().getAnimation()== 714)	{
							try {
								sleep(1000);
							} catch (InterruptedException e) {
								// TODO Auto-generated catch block
								e.printStackTrace();
							}
					}
				}
			state = State.WALKTOECTOHERB;
			}
		}

so then this (what i had in the beginning, with just a little tweaks wink.png )

 

public void onStart() {
		if (client.getInventory().contains(ectophial)
			&&!myPlayer().isInArea(EctoArea))	{
				client.getInventory().interactWithId(ectophial, "Empty");
				if (myPlayer().getAnimation()== 714)	{
					while (myPlayer().getAnimation()== 714)	{
							try {
								sleep(1000);
							} catch (InterruptedException e) {
	 						e.printStackTrace();
							}
					}
				}
			state = State.WALKTOECTOHERB;
			}
		}
  • Author

its telling me to put a try and catch method on 

client.getInventory().interactWithId(ectophial, "Empty");
Guest
This topic is now closed to further replies.

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.