UberJason 41 Share Posted August 24, 2019 Since the script I'm trying to make isn't all that special and being my first script, if it'll help I'll share the current source in a bit after some more fiddling. I'm trying to make a muling script. Currently, I have it set to be able to walk to its destination, the GE if it currently isn't already there. That isn't an issue and seems to work just fine. I also have a dialog pop up that stores a players name to trade as a string, and I'm trying to get it to interact with the player by that name if in the area, but I'm not sure what the correct way to check if that player exists. Here's what I have for this right now which is wrong: if (tradeArea.contains(nameToTrade)) - if not contains, what else could I use to check a string in an area? Link to comment Share on other sites More sharing options...
UberJason 41 Author Share Posted August 24, 2019 Think I might have gotten it working, gotta test it rn to check Link to comment Share on other sites More sharing options...
UberJason 41 Author Share Posted August 24, 2019 Meh, I've got nothing to hide. Still worth noting that this is going to be my first script so please no hurt. ;-; It seems not to work correctly anyway, so here's what I've got: import javax.swing.JOptionPane; import org.dreambot.api.methods.Calculations; 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; @ScriptManifest(author = "4ng1f1sh", name = "Muler", version = 1.0, description = "Muler", category = Category.MONEYMAKING) public class Main extends AbstractScript { String nameToTrade; private final Area tradeArea = new Area(3160, 3487, 3169, 3481); public void onStart() { nameToTrade = JOptionPane.showInputDialog("Enter name of person to trade"); } @Override public int onLoop() { if (tradeArea.contains(getLocalPlayer())) { log("AFKing at Grand Exchange"); } else { log("Walking to Grand Exchange"); getWalking().walk(tradeArea.getRandomTile()); sleep(Calculations.random((int) 1250.3000)); } if (tradeArea.equals(nameToTrade)) { getTrade().tradeWithPlayer(nameToTrade); sleep(5000); getTrade().acceptTrade(1); sleep(5000); getTrade().acceptTrade(2); } else { log("Player not in trade area"); } return 500; } public int onEnd() { return 0; } } Link to comment Share on other sites More sharing options...
UberJason 41 Author Share Posted August 24, 2019 OR if i'm just doing it completely wrong, that'd be helpful to know too, that'd be all I'd need to know. Link to comment Share on other sites More sharing options...
UberJason 41 Author Share Posted August 24, 2019 Got it, looks to be working now Link to comment Share on other sites More sharing options...
Leanche 2 Share Posted August 24, 2019 Hey, To check if player exists in yours area, you can iterate over every player in the area, just replace "name" with the name of a player you try to find. getPlayers().all().stream().anyMatch(player -> player != null && player.getName().equalsIgnoreCase(name)) Link to comment Share on other sites More sharing options...
UberJason 41 Author Share Posted August 24, 2019 Ok, update. Now I'm trying to get it to click accept. Nothing I've tried is working. Here's what I've got now: import java.awt.Rectangle; import javax.swing.JOptionPane; import org.dreambot.api.methods.Calculations; 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; @ScriptManifest(author = "4ng1f1sh", name = "Muler", version = 1.0, description = "Muler", category = Category.MONEYMAKING) public class Main extends AbstractScript { String nameToTrade; private final Area tradeArea = new Area(3160, 3487, 3169, 3481); public void onStart() { nameToTrade = JOptionPane.showInputDialog("Name of slave"); } @Override public int onLoop() { if (!tradeArea.contains(getLocalPlayer())) { getWalking().walk(tradeArea.getRandomTile()); } else if (tradeArea.contains(getLocalPlayer())) { getTrade().tradeWithPlayer(nameToTrade); sleep(Calculations.random(500, 1000)); } else if (getTrade().isOpen()) { sleep(100, 500); getMouse().click(new Rectangle(228, 195, 287, 196)); sleep(Calculations.random(100, 250)); getMouse().click(new Rectangle(228, 195, 287, 196)); } else { } return Calculations.random(1250, 3500); } public int onEnd() { return 0; } } What I'm now not understanding is why it ain't clicking those rectangles I have set. I thought that'd for sure work. Link to comment Share on other sites More sharing options...
UberJason 41 Author Share Posted August 24, 2019 2 minutes ago, Leanche said: Hey, To check if player exists in yours area, you can iterate over every player in the area, just replace "name" with the name of a player you try to find. getPlayers().all().stream().anyMatch(player -> player != null && player.getName().equalsIgnoreCase(name)) Interesting. Thanks! I've already done away with trying to do something based on whether the target player is in the area, but with that I might try doing so again. Link to comment Share on other sites More sharing options...
Leanche 2 Share Posted August 24, 2019 With the mouse clicks, you can either increase Sleep Time, or try using sleepUntil(() -> getMouse().click(new Rectangle(228, 195, 287, 196)), 5000); Link to comment Share on other sites More sharing options...
Nuclear Nezz 2040 Share Posted August 24, 2019 You can also use the Trade api for trades. getTrade().acceptTrade() Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.