hilarion4 12 Share Posted February 25, 2023 Im new and im trying to code some dreamt scripts. here's my code. Quote import org.dreambot.api.methods.item.GroundItems; import org.dreambot.api.script.AbstractScript; import org.dreambot.api.script.ScriptManifest; import org.dreambot.api.utilities.Logger; import org.dreambot.api.utilities.Sleep; import org.dreambot.api.wrappers.interactive.NPC; import org.dreambot.api.wrappers.items.GroundItem; import org.dreambot.api.script.Category; import org.dreambot.api.methods.interactive.NPCs; @ScriptManifest(name = "Chicken Killer", description = "My script description!", author = "Developer Name", version = 1.0, category = Category.COMBAT, image = "") public class teste extends AbstractScript { GroundItem pena = GroundItems.closest("Feather"); NPC chicken = NPCs.closest("Chicken"); private int state = 0; @Override public int onLoop() { if (state == 0) { matar(); } if (state != 0) { coletar(); } return 0; } private void matar() { if (chicken != null) { chicken.interact("Attack"); Logger.log("Atacou"); Sleep.sleep(4000,5000); state++; } } private void coletar() { if (pena != null) { pena.interact("Take"); Logger.log("Pegou"); state = 0; } } } Link to comment Share on other sites More sharing options...
xyz111 86 Share Posted February 25, 2023 Welcome! Taking a quick look I would advise to search for the closest npc every time before attacking and null checking. If you search once and that npc dies it is now null. hilarion4 1 Link to comment Share on other sites More sharing options...
hilarion4 12 Author Share Posted February 25, 2023 Thank you very much!!! Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now