Polish Civil 90 Share Posted January 17, 2015 /* */ > // Link to comment Share on other sites More sharing options...
Fran 99 Share Posted February 15, 2015 @Ericthecmh @Chris I have a question regarding the code (I am a new scripter), this part: if (!getLocalPlayer().isInCombat()) { // If I'm not in combat... // Get chicken NPC chicken = getNpcs().getClosest("Chicken"); // Uses a filter to get the closest NPC (to check for HP and other things) chicken = getNpcs().getClosest(new Filter<NPC>() { @Override public boolean match(NPC npc) { return npc != null && npc.getName().equals("Chicken") && npc.getActions().length > 0 && !npc.isInCombat(); } Where can I find what each of these getXXXX means? For exmaple, that (!getLocalPlayer().isInCombat()) means that if the player is not in combat? or getClosest will get the closest chicken? Let me know if I wasn't explicit enough, thanks in advance! Link to comment Share on other sites More sharing options...
Kristoffer 24 Share Posted February 15, 2015 @Ericthecmh @Chris I have a question regarding the code (I am a new scripter), this part: if (!getLocalPlayer().isInCombat()) { // If I'm not in combat... // Get chicken NPC chicken = getNpcs().getClosest("Chicken"); // Uses a filter to get the closest NPC (to check for HP and other things) chicken = getNpcs().getClosest(new Filter<NPC>() { @Override public boolean match(NPC npc) { return npc != null && npc.getName().equals("Chicken") && npc.getActions().length > 0 && !npc.isInCombat(); } Where can I find what each of these getXXXX means? For exmaple, that (!getLocalPlayer().isInCombat()) means that if the player is not in combat? or getClosest will get the closest chicken? Let me know if I wasn't explicit enough, thanks in advance! http://dreambot.org/javadocs/ Link to comment Share on other sites More sharing options...
Vlad 216 Share Posted February 15, 2015 @Ericthecmh @Chris I have a question regarding the code (I am a new scripter), this part: if (!getLocalPlayer().isInCombat()) { // If I'm not in combat... // Get chicken NPC chicken = getNpcs().getClosest("Chicken"); // Uses a filter to get the closest NPC (to check for HP and other things) chicken = getNpcs().getClosest(new Filter<NPC>() { @Override public boolean match(NPC npc) { return npc != null && npc.getName().equals("Chicken") && npc.getActions().length > 0 && !npc.isInCombat(); } Where can I find what each of these getXXXX means? For exmaple, that (!getLocalPlayer().isInCombat()) means that if the player is not in combat? or getClosest will get the closest chicken? Let me know if I wasn't explicit enough, thanks in advance! DreamBot documentation: http://dreambot.org/javadocs/ getNpcs() and its methods would be the in the NPCs and NPC classes, getLocalPlayer() and its methods would would be in the Players and Player classes, etc. "(!getLocalPlayer().isInCombat()) means that if the player is not in combat?" - Correct. "getClosest will get the closest chicken?" - Correct. Link to comment Share on other sites More sharing options...
Fran 99 Share Posted February 15, 2015 DreamBot documentation: http://dreambot.org/javadocs/ getNpcs() and its methods would be the in the NPCs and NPC classes, getLocalPlayer() and its methods would would be in the Players and Player classes, etc. "(!getLocalPlayer().isInCombat()) means that if the player is not in combat?" - Correct. "getClosest will get the closest chicken?" - Correct. @Vlad @Kristoffer One question, here: http://dreambot.org/javadocs/org/dreambot/api/methods/interactive/NPCs.html in NPCs, how do I interpret this method? Like, where would I enter the monster IDs to apply this method in my code?: getClosestpublic NPC getClosest(java.lang.Integer... ids)Gets the closest NCP to your player Parameters: ids - ID's to look for Returns: closest NPC @Pandemic can you please answer above question? thank you very much in advance. Basically, how to interpret the NPC methods, so I can finish my code. Again, thanks Link to comment Share on other sites More sharing options...
Pandemic 2711 Share Posted February 15, 2015 @Vlad @Kristoffer One question, here: http://dreambot.org/javadocs/org/dreambot/api/methods/interactive/NPCs.html in NPCs, how do I interpret this method? Like, where would I enter the monster IDs to apply this method in my code?: getClosest public NPC getClosest(java.lang.Integer... ids)Gets the closest NCP to your playerParameters: ids - ID's to look for Returns: closest NPC @Pandemic can you please answer above question? thank you very much in advance. Basically, how to interpret the NPC methods, so I can finish my code. Again, thanks To get an NPC with an ID you know (like if you wanted monster 5555), you'd do this: NPC npc = getNpcs().getClosest(5555); If the NPC has multiple IDs, just separate them by commas, like this: NPC npc = getNpcs().getClosest(5555, 5556, 5557); This will return the closest NPC with one of those ids, not all 3 of them. Link to comment Share on other sites More sharing options...
Vlad 216 Share Posted February 17, 2015 To get an NPC with an ID you know (like if you wanted monster 5555), you'd do this: NPC npc = getNpcs().getClosest(5555); If the NPC has multiple IDs, just separate them by commas, like this: NPC npc = getNpcs().getClosest(5555, 5556, 5557); This will return the closest NPC with one of those ids, not all 3 of them. To add to that, in my personal opinion, using Strings is better than IDs. If RS ever decides to change IDs around you'd be royally fucked whereas the chances of them changing names on a wide scale are slim to none. You should also probably learn Java and how to read Java documentation before attempting to script if you want to be really successful. After doing that just look at some snippets/open source stuff to see how others are doing things. Make some easy shit like woodcutting or cooking or something and then take a look at the full API before trying advanced stuff. In general, hard scripts require more programming skills. For example, using RuneScape settings requires further programming knowledge(Bitwise operations). Stuff like Hunter would technically be better using Java Queues unless you're a noob -cough- -cough-. Link to comment Share on other sites More sharing options...
Fran 99 Share Posted February 17, 2015 I am getting the following error when compiling: "Exception InterruptedException is not compatible with throws clause in AbstractScript.onLoop()" Any idea? @Vlad Link to comment Share on other sites More sharing options...
Vlad 216 Share Posted February 17, 2015 I am getting the following error when compiling: "Exception InterruptedException is not compatible with throws clause in AbstractScript.onLoop()" Any idea? @Vlad Why are you throwing InterruptedException in a script??? Find out why and work around it. >Why you should learn Java first. Link to comment Share on other sites More sharing options...
Fran 99 Share Posted February 17, 2015 Why are you throwing InterruptedException in a script??? Find out why and work around it. >Why you should learn Java first. I've resolved Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.