smh1 0 Share Posted January 3, 2021 import org.dreambot.api.methods.Calculations; import org.dreambot.api.methods.container.impl.Inventory; import org.dreambot.api.methods.container.impl.bank.Bank; import org.dreambot.api.methods.interactive.GameObjects; import org.dreambot.api.methods.interactive.NPCs; import org.dreambot.api.methods.item.GroundItems; import org.dreambot.api.methods.map.Area; import org.dreambot.api.script.AbstractScript; import org.dreambot.api.script.Category; import org.dreambot.api.script.ScriptManifest; import org.dreambot.api.wrappers.interactive.GameObject; import org.dreambot.api.wrappers.interactive.NPC; import org.dreambot.api.wrappers.items.GroundItem; @ScriptManifest( author = "smh1", description = "Cooker", category = Category.COOKING, version = 0.01, name = "Speed Cooker" ) public class Main extends AbstractScript { Area cookingSpot = new Area(3043, 4972, 1,0); public int uShark = 383; public int shark = 385; public int banker = 3194; public int fire = 26185; GroundItem uncookedShark = GroundItems.closest(uShark); State state; @Override public int onLoop() { switch (getState()) { case BANKING: NPC bankMan = NPCs.closest(banker); bankMan.interact("Bank"); sleepUntil(() -> Bank.isOpen(), Calculations.random(1000, 2000)); if (Bank.isOpen() && Inventory.isEmpty()) { Bank.withdraw(uShark, 28); sleepUntil(() -> Inventory.isFull(), Calculations.random(50, 120)); Bank.close(); } else if (Inventory.containsAll(shark)) { Bank.depositAllItems(); sleepUntil(() -> Inventory.isEmpty(), 100, 250); Bank.withdrawAll(uShark); sleepUntil(() -> Inventory.containsAll(uShark), Calculations.random(50, 200)); Bank.close(); } break; case DROPPING: Inventory.drop(uShark); break; case COOKING: Inventory.get(uShark).interact("Use"); sleepUntil(() -> Inventory.isItemSelected(), Calculations.random(10, 70)); GameObject firee = GameObjects.closest(fire); firee.interact("Use"); GroundItem uncookedShark = GroundItems.closest(uShark); if (uncookedShark != null) uncookedShark.interact("Take"); break; } return 0; } private enum State{ BANKING,DROPPING,COOKING } private State getState() { if (Inventory.isEmpty() || Inventory.containsAll(shark)){ state = State.BANKING; log("Banking"); }else if (Inventory.containsAll(uShark) && !Bank.isOpen()){ state = State.DROPPING; log("Dropping"); }else if (uncookedShark.equals(27) && Inventory.contains(uShark==1)); state = State.COOKING; log("Cooking"); return state; } public void onStart(){ log("Bot has started"); } public void onExit(){ } } This is when I try running it with full inv of sharks. He just spam clicks on shark and then the fire. this happens when I try running it with no sharks in my inv. Link to comment Share on other sites More sharing options...
TheCloakdOne 389 Share Posted January 3, 2021 you need to check your nulls. Inventory.get(uShark) for example will return null when calling it so .interact() will fire a NPE Link to comment Share on other sites More sharing options...
smh1 0 Author Share Posted January 3, 2021 I'm really lost tbh.. I need you to elaborate more, because I'm really new to scripting.. And I need your help, man! Link to comment Share on other sites More sharing options...
yeeter 521 Share Posted January 3, 2021 24 minutes ago, smh1 said: I'm really lost tbh.. I need you to elaborate more, because I'm really new to scripting.. And I need your help, man! It sounds to me like you don't have much actual Java programming experience. I would suggest going onto YouTube and finding an introduction to Java video. Should be a couple hours long and it will help you a lot more than waiting for answers on the forum post. Link to comment Share on other sites More sharing options...
smh1 0 Author Share Posted January 3, 2021 Thanks! Will do! Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.