zorichy 1 Share Posted November 27, 2018 So, I'm trying to make a script that logs you out if there's another player in a certain area (for semi-legit AFK-ing). I'm testing this in the chicken area in Lumbridge, this is my script so far: package Main; import org.dreambot.api.methods.map.Area; import org.dreambot.api.methods.tabs.Tabs; import org.dreambot.api.wrappers.interactive.Player; import org.dreambot.api.script.AbstractScript; import org.dreambot.api.script.Category; import org.dreambot.api.script.ScriptManifest; @ScriptManifest(category = Category.MISC, name = "LJS Logout", author = "LJS", version = 0.1) public class Main extends AbstractScript { @Override public void onStart() { log("LJS Logout started"); } Area chickArea = new Area(3224, 3302, 3239, 3286); // Chicken Area @Override public int onLoop() { if (chickArea.contains((Player) getTabs()).logout()); return 5; } @Override public void onExit() { log("LJS Logout ended"); } } Is that somewhat correct? This is the very first time trying to make a script. I just checked some tutorials on the forum & Youtube and that's all. Sorry for being a total noob in this, but this is all kinda cool! Getting this error: Error:(23, 44) java: incompatible types: org.dreambot.api.methods.tabs.Tabs cannot be converted to org.dreambot.api.wrappers.interactive.Player What can I do? Cheers! Link to comment Share on other sites More sharing options...
Hashtag 8670 Featured Comment Share Posted November 27, 2018 Well. Obviously, it's not correct as you're receiving error messages. You're casting client's instance of Tabs to Player type and checking if an area contains Player class. You also want the logout statement to be inside the if statement's curly brackets (you're missing the opening curly bracket). public int onLoop() { //search for a player using closest method and a lambda expression. First, make sure the player isn't your own player. Then check if it's in the area. Player player = getPlayers().closest(p -> p != null && !p.equals(getLocalPlayer()) && chickenArea.contains(p)); //if a player was found if (player != null) { //logout getTabs().logout(); } //checks for players every 5ms, you might want to change that. return 5; } The above code should work like you intended. However, I suggest you to watch a few tutorials on Java and then moving onto scripting. Knowing the basics of Java will help a lot when scripting. Link to comment Share on other sites More sharing options...
zorichy 1 Author Share Posted November 27, 2018 Thanks a lot for the quick reply! I'll be checking out what you've send. Just wanted to make this work, run it and in the meanwhile check some more tutorials. Got a bit too excited I guess Link to comment Share on other sites More sharing options...
zorichy 1 Author Share Posted November 27, 2018 So... IT WORKS! First got another error, but that was because the area was called chickArea and you used chickenArea, but that's all ok now. Just one more question: is there a way to make the action faster? Like log out faster. 'Cause the mouse movement isn't the fastest and it's all the way up in the bot. Link to comment Share on other sites More sharing options...
Hashtag 8670 Share Posted November 27, 2018 3 minutes ago, zorichy said: So... IT WORKS! First got another error, but that was because the area was called chickArea and you used chickenArea, but that's all ok now. Just one more question: is there a way to make the action faster? Like log out faster. 'Cause the mouse movement isn't the fastest and it's all the way up in the bot. What you could do is make the mouse hop instantly by using getMouse().setAlwaysHop(true); Link to comment Share on other sites More sharing options...
zorichy 1 Author Share Posted November 29, 2018 Totally forgot to answer, but thanks a lot, 'cause that works 👍🏻 Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.