igetbanned Posted September 4, 2014 Share Posted September 4, 2014 Trying to make a Range Guild script, but the dialogue seems to be messing up on me. Here's what I have: NPC judge = npcs.closestThatContains("Competition Judge"); if (!getInventory().contains("Bronze Arrow") && !getEquipment().contains("Bronze Arrow")) judge.interact("Talk-to"); getDialogues().clickContinue(); sleep(1500); getDialogues().selectOption("Sure, I'll give it a go."); sleep(1500); getDialogues().clickContinue(); sleep(1000); It just loops back to "Talk-to" and clicks continue once, then restarts again and talks to the judge. A never ending cycle. I tried removing the if statement and even adding another but it didn't work. Can't test the latter part of my script because I can't even get passed the dialogue portion, lol. Help? Link to comment Share on other sites More sharing options...
Precise Posted September 4, 2014 Share Posted September 4, 2014 (edited) Trying to make a Range Guild script, but the dialogue seems to be messing up on me. Here's what I have: NPC judge = npcs.closestThatContains("Competition Judge"); if (!getInventory().contains("Bronze Arrow") && !getEquipment().contains("Bronze Arrow")) judge.interact("Talk-to"); getDialogues().clickContinue(); sleep(1500); getDialogues().selectOption("Sure, I'll give it a go."); sleep(1500); getDialogues().clickContinue(); sleep(1000); It just loops back to "Talk-to" and clicks continue once, then restarts again and talks to the judge. A never ending cycle. I tried removing the if statement and even adding another but it didn't work. Can't test the latter part of my script because I can't even get passed the dialogue portion, lol. Help? you need to change the structure, it isn't a very efficient way of doing it. NPC judge = npcs.closestThatContains("Competition Judge"); if(judge != null) { if (!getInventory().contains("Bronze Arrow") && !getEquipment().contains("Bronze Arrow")) { if(getDialogues().isPendingContinuation()) { getDialogues().clickContinue(); sleep(850); } else if(getDialogues().inDialogue()) { getDialogues().selectOption("Sure, I'll give it a go."); sleep(850); } else { judge.interact("Talk-to"); } } } Edited September 4, 2014 by Precise Link to comment Share on other sites More sharing options...
Ericthecmh Posted September 4, 2014 Share Posted September 4, 2014 Even with that, don't use a static wait time. That's a sure sign of a bot. At least randomize your sleep time. Link to comment Share on other sites More sharing options...
Precise Posted September 4, 2014 Share Posted September 4, 2014 Even with that, don't use a static wait time. That's a sure sign of a bot. At least randomize your sleep time. that's up for him to do ;) Link to comment Share on other sites More sharing options...
igetbanned Posted September 4, 2014 Author Share Posted September 4, 2014 Even with that, don't use a static wait time. That's a sure sign of a bot. At least randomize your sleep time. you need to change the structure, it isn't a very efficient way of doing it. NPC judge = npcs.closestThatContains("Competition Judge"); if(judge != null) { if (!getInventory().contains("Bronze Arrow") && !getEquipment().contains("Bronze Arrow")) { if(getDialogues().isPendingContinuation()) { getDialogues().clickContinue(); sleep(850); } else if(getDialogues().inDialogue()) { getDialogues().selectOption("Sure, I'll give it a go."); sleep(850); } else { judge.interact("Talk-to"); } } } Worked, thanks Changed to this now, hope I did the sleeping right: NPC judge = npcs.closestThatContains("Competition Judge"); if(judge != null) { if (!getInventory().contains("Bronze Arrow") && !getEquipment().contains("Bronze Arrow")) { if(getDialogues().isPendingContinuation()) { getDialogues().clickContinue(); sleep(MethodProvider.gRandom(400, 850)); } else if(getDialogues().inDialogue()) { getDialogues().selectOption("Sure, I'll give it a go."); sleep(MethodProvider.gRandom(400, 850)); } else { judge.interact("Talk-to"); } } } Might I ask why I always see if ( != null ) in scripts? What is it significant about that condition? Can't it just not be used with the same outcome? Link to comment Share on other sites More sharing options...
Precise Posted September 4, 2014 Share Posted September 4, 2014 Worked, thanks Changed to this now, hope I did the sleeping right: NPC judge = npcs.closestThatContains("Competition Judge"); if(judge != null) { if (!getInventory().contains("Bronze Arrow") && !getEquipment().contains("Bronze Arrow")) { if(getDialogues().isPendingContinuation()) { getDialogues().clickContinue(); sleep(MethodProvider.gRandom(400, 850)); } else if(getDialogues().inDialogue()) { getDialogues().selectOption("Sure, I'll give it a go."); sleep(MethodProvider.gRandom(400, 850)); } else { judge.interact("Talk-to"); } } } Might I ask why I always see if ( != null ) in scripts? What is it significant about that condition? Can't it just not be used with the same outcome? well if the NPC isn't there it will return null, and when you invoke the method judge.interact("Talk-to") it will throw a null pointer error. Link to comment Share on other sites More sharing options...
igetbanned Posted September 4, 2014 Author Share Posted September 4, 2014 well if the NPC isn't there it will return null, and when you invoke the method judge.interact("Talk-to") it will throw a null pointer error. Got it I've tried it on my own, and everything runs smooth now except for the part where it has to close the new interface that opens once an arrow is fired. Here's the new code: if(judge != null) { if (!getInventory().contains("Bronze Arrow") && !getEquipment().contains("Bronze Arrow")) { if(getDialogues().isPendingContinuation()) { getDialogues().clickContinue(); sleep(MethodProvider.gRandom(400, 850)); } else if(getDialogues().inDialogue()) { getDialogues().selectOption("Sure, I'll give it a go."); sleep(MethodProvider.gRandom(400, 850)); } else { judge.interact("Talk-to"); } } } while (getInventory().contains("Bronze Arrow")) { getEquipment().equip(EquipmentSlot.ARROWS, "Bronze Arrow"); } while (getEquipment().isWearingItem(EquipmentSlot.ARROWS, "Bronze Arrow")) { Targets.interact("Fire-at"); sleep(MethodProvider.gRandom(600, 1250)); getInterfaces().closeOpenInterface(); } I tried using interfaces, Interfaces, getInterfaces().getOpenInterfaces().close() Anything I could think of. Do I have to create a static variable for the open interface, and add .close() to it or something? Link to comment Share on other sites More sharing options...
Extreme Scripts Posted September 4, 2014 Share Posted September 4, 2014 You could do it several ways: Interact with the interface child when its parent becomes visible Close the open interface using the default methods when the interface becomes visible #2 is the easiest and can be done like so: interfaces.closeOpenInterface(); Of course these will both require checks that the interface is visible + not null before interacting with them. Link to comment Share on other sites More sharing options...
Swizzbeat Posted September 4, 2014 Share Posted September 4, 2014 I added a method in the dialogues class for completing a dialogue with the specified actions, just so it's easier. Might I ask why I always see if ( != null ) in scripts? What is it significant about that condition? Can't it just not be used with the same outcome? Instance variables don't hold the object itself but instead a pointer to the objects data out on the heap. If that variable is pointing to nothing it will contain a "null" reference and throw NullPointerExceptions if you try to use the object it's pointing (or not, in this case) to. The variable itself just contains an empty pointer. I would recommend reading this: http://osbot.org/forum/topic/47833-java-pass-by-value/ Link to comment Share on other sites More sharing options...
igetbanned Posted September 5, 2014 Author Share Posted September 5, 2014 You could do it several ways: Interact with the interface child when its parent becomes visible Close the open interface using the default methods when the interface becomes visible #2 is the easiest and can be done like so: interfaces.closeOpenInterface(); Of course these will both require checks that the interface is visible + not null before interacting with them. Like so? if (interfaces.getOpenInterface().isVisible() && interfaces.getOpenInterface() != null) interfaces.closeOpenInterface(); Tested and it returns an error I might just try the parent/child method but I'll have to look at the API because I know nothing about that lol Link to comment Share on other sites More sharing options...
Alek Posted September 5, 2014 Share Posted September 5, 2014 You shouldn't be relying on static sleeps to get you to the next dialogue. If it takes any longer than 1500ms to the next dialogue, your script will fail. What if the mouse misclicks? What if you're connected to a laggy server? Link to comment Share on other sites More sharing options...
igetbanned Posted September 5, 2014 Author Share Posted September 5, 2014 (edited) You shouldn't be relying on static sleeps to get you to the next dialogue. If it takes any longer than 1500ms to the next dialogue, your script will fail. What if the mouse misclicks? What if you're connected to a laggy server? Eric had mentioned that so I changed the script to be random sleep times If I did something wrong with the new sleep times please let me know: if(judge != null) { if (!getInventory().contains("Bronze Arrow") && !getEquipment().contains("Bronze Arrow")) { if(getDialogues().isPendingContinuation()) { getDialogues().clickContinue(); sleep(MethodProvider.gRandom(400, 850)); } else if(getDialogues().inDialogue()) { getDialogues().selectOption("Sure, I'll give it a go."); sleep(MethodProvider.gRandom(400, 850)); } else { judge.interact("Talk-to"); } } } while (getInventory().contains("Bronze Arrow")) { getEquipment().equip(EquipmentSlot.ARROWS, "Bronze Arrow"); } while (getEquipment().isWearingItem(EquipmentSlot.ARROWS, "Bronze Arrow")) { Targets.interact("Fire-at"); sleep(MethodProvider.gRandom(600, 1250)); getInterfaces().closeOpenInterface(); } Still getting the interface issue, just sits there when the results of the arrow pop up. Perhaps it's not recognized as an interface? Idk Edited September 5, 2014 by igetbanned Link to comment Share on other sites More sharing options...