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.

How to buy items from a store/check if they are out?

Featured Replies

I want to be able to buy different items from a store, let's say a General store. And if they are out of said item, to hop worlds (p2p worlds). I tried digging through some tutorials, and using widgets myself, but its not working. Any ideas?

I want to be able to buy different items from a store, let's say a General store. And if they are out of said item, to hop worlds (p2p worlds). I tried digging through some tutorials, and using widgets myself, but its not working. Any ideas?

There is a store class to handle most things for you :) It can be found here and it should hold everything you need

  • Author

There is a store class to handle most things for you smile.png It can be found here and it should hold everything you need

 

Omg that's great!! So much easier haha. Thanks a ton!

Omg that's great!! So much easier haha. Thanks a ton!

You're welcome :) If you run into any issues let me know :D

  • Author

You're welcome smile.png If you run into any issues let me know biggrin.png

 

Hey, Solution. Could you help me with this?

 

So in this case, I have it trade the NPC nearby and buy all of the supply of 4 different items. I want it to buy them all, and once out, to hop worlds and continue. I can't seem to make it work because the way I currently have it, it opens the Store but doesn't buy. If I put the buying code outside the trade if then it does it but once its out, it doesn't hop but rather keeps spam trading the NPC.

 

Sorry if that's a bit unclear, I can explain more if need be.

case BUY:

                if ((getNpcs().closest("NPC") !=null) && (!getStore().isOpen())) {
                    getNpcs().closest("NPC").interact("Trade");
                    wait(100,200);

                    if ((getStore().isOpen()) /*&& (getStore().contains("Item1" , "Item2" , "Item3" , "Item4"))*/) {
                        if (getStore().getAmount("Item1") > 0) {
                            getStore().buy("Item1", 10);
                            wait(100, 200);
                        } else if (getStore().getAmount("Item2") > 0) {
                            getStore().buy("Item2", 10);
                            wait(100, 200);
                        } else if (getStore().getAmount("Item3") > 0) {
                            getStore().buy("Item3", 10);
                            wait(100, 200);
                        } else if (getStore().getAmount("Item4") > 0) {
                            getStore().buy("Item4" , 10);
                            wait(100,200);
                        }
                        else {
                            getStore().close();
                            wait(100,200);
                            worlds.hopToP2PWorld();
                        }
                    }
                }
           
                break;

 

Hey, Solution. Could you help me with this?

 

So in this case, I have it trade the NPC nearby and buy all of the supply of 4 different items. I want it to buy them all, and once out, to hop worlds and continue. I can't seem to make it work because the way I currently have it, it opens the Store but doesn't buy. If I put the buying code outside the trade if then it does it but once its out, it doesn't hop but rather keeps spam trading the NPC.

 

Sorry if that's a bit unclear, I can explain more if need be.

case BUY:

                if ((getNpcs().closest("NPC") !=null) && (!getStore().isOpen())) {
                    getNpcs().closest("NPC").interact("Trade");
                    wait(100,200);

                    if ((getStore().isOpen()) /*&& (getStore().contains("Item1" , "Item2" , "Item3" , "Item4"))*/) {
                        if (getStore().getAmount("Item1") > 0) {
                            getStore().buy("Item1", 10);
                            wait(100, 200);
                        } else if (getStore().getAmount("Item2") > 0) {
                            getStore().buy("Item2", 10);
                            wait(100, 200);
                        } else if (getStore().getAmount("Item3") > 0) {
                            getStore().buy("Item3", 10);
                            wait(100, 200);
                        } else if (getStore().getAmount("Item4") > 0) {
                            getStore().buy("Item4" , 10);
                            wait(100,200);
                        }
                        else {
                            getStore().close();
                            wait(100,200);
                            worlds.hopToP2PWorld();
                        }
                    }
                }
           
                break;
  1. Don't use "wait()" when you want the script to sleep. Use ConditionalSleep for dynamic sleeping

    open store
    new ConditionalSleep(5000
       public boolean condition() {
           return store is open;
       }
    }.sleep();
    
    //it will sleep maximum 5000 ms or until the store is open
  2. Your getState() or w/e it's called is flawed

Edited by Woody

  • Author

 

  1. Don't use "wait()" when you want the script to sleep. Use ConditionalSleep for dynamic sleeping

    open store
    new ConditionalSleep(5000
       public boolean condition() {
           return store is open;
       }
    }.sleep();
    
    //it will sleep maximum 5000 ms or until the store is open
  2. Your getState() or w/e it's called is flawed

 

 

Why do you say my getState() is flawed? I'm not sure what you mean by this.

 

Why do you say my getState() is flawed? I'm not sure what you mean by this.

 

I think he is talking about your onLoop() because unless I am blind your getState() wasn't even provided.

 

Here is an example of what I used in one of my scripts:

NPC gerrant = getNpcs().closest("Gerrant");
    		if(gerrant == null){
    			log("[Error] Gerrant not found!");
    			return 1000;
    		}
    		if(gerrant.interact("Trade")){
    			new ConditionalSleep(6000){
    				@Override
    				public boolean condition() throws InterruptedException {
    					return getWidgets().isVisible(300);
    				}
    			}.sleep();
    		}

I was using Widgets and not the store class.

  • Author

I think he is talking about your onLoop() because unless I am blind your getState() wasn't even provided.

 

Here is an example of what I used in one of my scripts:

NPC gerrant = getNpcs().closest("Gerrant");
    		if(gerrant == null){
    			log("[Error] Gerrant not found!");
    			return 1000;
    		}
    		if(gerrant.interact("Trade")){
    			new ConditionalSleep(6000){
    				@Override
    				public boolean condition() throws InterruptedException {
    					return getWidgets().isVisible(300);
    				}
    			}.sleep();
    		}

I was using Widgets and not the store class.

 

Ohh well if that's the case, I just didn't copy down the getState() part onto here lol, I definitely have it in the script though. Hmm I'm gonna try to stick to using the store class. I was able to open the store, just not efficiently buy items :P

Ohh well if that's the case, I just didn't copy down the getState() part onto here lol, I definitely have it in the script though. Hmm I'm gonna try to stick to using the store class. I was able to open the store, just not efficiently buy items :P

Want to post what you fixed so far? Also I am guessing you arn't actually putting "Item1" and instead the items id correct?

  • Author

Want to post what you fixed so far? Also I am guessing you arn't actually putting "Item1" and instead the items id correct?

 

Yes of course haha, just changed the items/npc to obscure it for now. I'm not home so can't post it, but the only thing I tried was creating separate cases for Buy and Talk(trade) so for one he'll trade with the npc, and then buy. It's just not going smoothly though. I must be messing something up when trying to buy multiple of different items.

Yes of course haha, just changed the items/npc to obscure it for now. I'm not home so can't post it, but the only thing I tried was creating separate cases for Buy and Talk(trade) so for one he'll trade with the npc, and then buy. It's just not going smoothly though. I must be messing something up when trying to buy multiple of different items.

Shouldn't be necessary, my script buys and opens feather packs using three states BUY,OPEN,WAIT.

  • Author

Shouldn't be necessary, my script buys and opens feather packs using three states BUY,OPEN,WAIT.

 

Yeah I figured it doesn't need to be so complicated. Before I left I switched it back to just 3 simple Buy, Walk to Shop, and Bank. I'm gonna have to look at it and see what I can do when I get home. Currently clueless as to what to fix.

Yeah I figured it doesn't need to be so complicated. Before I left I switched it back to just 3 simple Buy, Walk to Shop, and Bank. I'm gonna have to look at it and see what I can do when I get home. Currently clueless as to what to fix.

If you still need help after you have tried you can PM me your source and I will fix it.

  • Author

If you still need help after you have tried you can PM me your source and I will fix it.

 

Gonna test it when I get home. Thx!

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.