hilarion4 12 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; } } }
xyz111 90 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.
Recommended Posts
Archived
This topic is now archived and is closed to further replies.