Jump to content

Trying to learn how to work with GE


heervangrijsburg

Recommended Posts

  Reveal hidden contents

As the title says, I try to learn how to work with the GE. What I'm trying to do with this bot is that it gets coins and logs from the bank sells the logs at the GE (currently the logs can be sold at 1 gp later I will try to get the right prices from osbuddy).

 

then the bot would have to buy a steel axe at the GE (currently all coins in the inventory can be used for this later I will also try to get the right prices from osbuddy).

Unfortunately, the bot clicks randomly succeeds to get the coins and logs from the bank than he opens the GE to start clicking all over the place. Would anyone be able to look at my code and maybe give me a quick tutorial on how to work with the GE (preferably with a few examples)

thank you in advance
heervangrijsburg

 

 

Link to comment
Share on other sites

  On 11/11/2018 at 8:36 PM, heervangrijsburg said:

As the title says, I try to learn how to work with the GE. What I'm trying to do with this bot is that it gets coins and logs from the bank sells the logs at the GE (currently the logs can be sold at 1 gp later I will try to get the right prices from osbuddy).

then the bot would have to buy a steel axe at the GE (currently all coins in the inventory can be used for this later I will also try to get the right prices from osbuddy).

Unfortunately, the bot clicks randomly succeeds to get the coins and logs from the bank than he opens the GE to start clicking all over the place. Would anyone be able to look at my code and maybe give me a quick tutorial on how to work with the GE (preferably with a few examples)

thank you in advance

heervangrijsburg

Expand  

There's a few things to address here... 

1. Try not to use static IDs, as these could change and it could break the script. Instead use a string literal to retrieve items 

if ( getInventory().contains("Logs") ) {}

2. Null check NPCs to avoid NullPointerExceptions, and move interactions to a conditional statement. This is so you can better deal with the success and failure events (true / false). 

NPC exchangeClerk = getNpcs().closest("Grand Exchange Clerk");

if ( exchangeClerk != null && exchangeClerk.interact("Exchange") ) {

	new ConditionalSleep(MethodProvider.random(2000, 2500)) {
		@Override
		public boolean condition() throws InterruptedException {
			return getGrandExchange().isOpen();
		}
	}.sleep();

}

3. Avoid while() statements, they are blocking the script onLoop(). The game environment is changing constantly and if the conditional for the while statement is unreachable your script will be unable to proceed. Instead write better conditionals. 

---

Spoiler Alert - if you want to use an event to handle this, here is my snippet. As you can see I need to remove the static IDs for Addy and Mith axe, I can do this using an API for the items and dynamically fill item IDs. 

  Reveal hidden contents

 

  • Like 1
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...