imancity Posted May 26, 2016 Share Posted May 26, 2016 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? Quote Link to comment Share on other sites More sharing options...
Solution Posted May 26, 2016 Share Posted May 26, 2016 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 1 Quote Link to comment Share on other sites More sharing options...
imancity Posted May 26, 2016 Author Share Posted May 26, 2016 There is a store class to handle most things for you It can be found here and it should hold everything you need Omg that's great!! So much easier haha. Thanks a ton! Quote Link to comment Share on other sites More sharing options...
Solution Posted May 26, 2016 Share Posted May 26, 2016 Omg that's great!! So much easier haha. Thanks a ton! You're welcome If you run into any issues let me know 1 Quote Link to comment Share on other sites More sharing options...
imancity Posted May 26, 2016 Author Share Posted May 26, 2016 You're welcome If you run into any issues let me know 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; Quote Link to comment Share on other sites More sharing options...
Woody Posted May 26, 2016 Share Posted May 26, 2016 (edited) 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; 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 Your getState() or w/e it's called is flawed Edited May 26, 2016 by Woody 1 Quote Link to comment Share on other sites More sharing options...
imancity Posted May 26, 2016 Author Share Posted May 26, 2016 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 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. Quote Link to comment Share on other sites More sharing options...
Lone Posted May 26, 2016 Share Posted May 26, 2016 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. 1 Quote Link to comment Share on other sites More sharing options...
imancity Posted May 26, 2016 Author Share Posted May 26, 2016 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 Quote Link to comment Share on other sites More sharing options...
Lone Posted May 26, 2016 Share Posted May 26, 2016 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? Quote Link to comment Share on other sites More sharing options...
imancity Posted May 26, 2016 Author Share Posted May 26, 2016 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. Quote Link to comment Share on other sites More sharing options...
Lone Posted May 26, 2016 Share Posted May 26, 2016 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. Quote Link to comment Share on other sites More sharing options...
imancity Posted May 26, 2016 Author Share Posted May 26, 2016 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. Quote Link to comment Share on other sites More sharing options...
Lone Posted May 27, 2016 Share Posted May 27, 2016 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. 1 Quote Link to comment Share on other sites More sharing options...
imancity Posted May 27, 2016 Author Share Posted May 27, 2016 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! Quote Link to comment Share on other sites More sharing options...