Jump to content

Allen

Members
  • Posts

    350
  • Joined

  • Last visited

  • Feedback

    100%

Everything posted by Allen

  1. A try-catch statement is a method of catching or throwing an error in the code without disrupting other portions of the code, it also allows you to define a specific exception(the type of error thrown): try { //here you put code that will "try" to be ran and "Caught" if an error occurs. } catch (Exception e) { e.printStackTrace(); // this will print the source of the error and all previous methods called to the line of the error. } There are a few instances where a try-catch is required, such as reading/writing to a file. Example: try { String sItemId = params[0]; // a string array of parameters int itemId = Integer.valuOf(sItemId); // this is what we are catching the exception for (what if sItemId equals "345s"? 's' cannot be parsed to an integer object! //blah } catch (NumberFormatException e) {// here we catch the error with as specific exception e.printStackTrace(); } Enums are a way of holding constant values. The advantage to enums over just many final primitive fields is that it can act as an encapsulated object(the data within the enum cannot be changed or edited, but the values can be accessed and the enum can be treated like an object). For example: public enum Food { SHRIMP(123,5), LOBSTER(456,20); int itemId; int heal; Food(int itemId, int heal) { this.itemId = itemId; this.heal = heal; } public int getItemId() { return itemId; } public int getHealValue() { return heal; } public static Food getFoodForItem(int itemId) { for(Food food : Food.values()) if(food.getItemId() == itemId) return food; return null; } } You can reference the enum by the following: public void eat(Food food) { player.heal(food.getHealValue()); } or public void eat(int itemId) { Food food = Food.getFoodForItem(itemId); if(food != null) player.heal(food.getHealValue()); } or if(food == Food.LOBSTER) { //blah } Enums can be a lot more powerful than this example, but since you're just starting this is enough They can also be a lot more simple, you could just use it as a reference: public enum CombatType{ MELEE, RANGE, MAGIC; } Use: CombatType currentType = CombatType.MELEE; //blah... switch(currentType) { case CombatType.MELEE: //blah: fight with sword break; case CombatType.RANGE: //blah: fight with crossbow break; case CombatType.MAGIC: //blah: fight with staff break; } EDIT: added example for try-catch, if you have any other questions pm me or ask here ;p BTW: I made a 5 on AP comp science(assuming that's what you're in when you said "computer science ap"), and I'll tell you: Neither enums or try-catch are on the exam. You're teacher isn't responding to you because IF you use something on the exam that is not taught in the class, you will not get full credit(on the free response for example). Just a heads up
  2. Allen

    Just Spam

    Thats like an entire extra click man the struggle is already real enuf with this chemistry
  3. Allen

    Just Spam

    http://prntscr.com/54sn26 edit: pauli exclusion, i missed the second blank tho it was 2.
  4. Allen

    Just Spam

    I'm doing chemistry modules
  5. Galaxy Note 4. http://www.phonearena.com/phones/compare/Samsung-Galaxy-Note-4,Apple-iPhone-6-Plus/phones/8577,8908
  6. Dex is great for making logos, vouch for him.
  7. If they were OSBot 1 scripts, I believe so. A lot of the owners didnt bother converting to OSBot 2 when the final change was made. There's actually a thread I believe posted by Alek where if a scripter later converted to OSBot 2, you can get credited for the script within 6 months after the convert to OSB2.0 in September. Let me try to find it. EDIT: http://osbot.org/forum/topic/60660-osbot-1-scripts-and-osbot-legacy-api/ It's a 30 day free trial for an identical OSBot 2 script of an OSBot 1 script that your purchased.
  8. http://prntscr.com/54nuuj Is the memory the client is currently using, not the loading bar. To load a bot client, click http://prntscr.com/54nv4w You'll be prompted to select an account, add one by clicking the settings button: http://prntscr.com/54nvhg
  9. WHEN I SAW THE THREAD TITLE THIS MOVIE CAME TO MIND INSTANTLY. And then I clicked thread and boom. So yeah, it's probably the worse movie I've seen in my entire life plus the ending made me want to rope + chair myself. I think the producers just through a bunch of autistic kids in a room and gave them pencil and paper.
  10. They're both just references to the instantiation of the Inventory class in MethodProvider. Although there's no reason in doing client.getInventory() (Client isn't even a subclass of MethodProvider so I'm not sure how you'd get this.client.inventory anyways), that'd be like doing this.bank.getInventory(). There's no reason to access a subclass of MethodProvider through another subclass. With Script being a subclass of MethodProvider, you have direct access to all of its reference variables and methods.
  11. Doesn't matter you can still get banned. But you can decrease your chances by not looking like a giant bot: -Do some quests -Dont train 1 skill for more than one day straight(I wouldn't even train 1 entire skill for more that 6 hours if you're on a fresh 07 account) -Babysit the bot and get in a cc and talk every now and then. All of these factors can help decrease your chance(assuming the client isnt detactable), age of your account most definitely won't help decrease the chance.
  12. Although you're not going to see any difference in performance storing the reference to the NPC object over an Integer object with its index. In fact, it'd actually force to to add to the code because I'd have to reference to the NPC object from NPCS#getLocalNPC(index) when writing. Thanks for the suggestion though, all feedback is appreciated
  13. I considered doing this and having a UI button on the screen to dump/update the file. The method to write is also not called unless a new NPC appears in the scene that has not already been dumped. Regarding the string suggestion, yes it may be more efficient(although its just a list of references to the object) however, the npc's do walk. A more ideal alteration would be to save the npc index in an ArrayList<Integer> if I were not going to list NPC's. I also considered instantiating the writer upon start and writing to it when necessary(or on close/stop), and closing the writer on script finish, but I wasnt sure of how efficient that would be vs how it is now. i.e. this: https://gist.github.com/kinztechcom/3b0a2fa5cf284fe830bb edit: project is on github now so if more changes are made i don't have to keep submitting just the class: https://github.com/kinztechcom/OSBot/blob/master/src/com/kinztech/scripts/npcdump/NpcDumpScript.java
  14. This script will dump all local npcs in the format "npcid x y". It would benefit anyone making an OS private server(since one's in development maybe they'll come across this and use it). package com.kinztech.scripts.npcdump; import java.io.BufferedWriter; import java.io.File; import java.io.FileWriter; import java.util.ArrayList; import org.osbot.rs07.api.model.NPC; import org.osbot.rs07.script.*; import org.osbot.utility.Logger.MessageType; /** * A script to dump local NPC spawns. * @author Allen K. * */ @ScriptManifest(author = "Allen", info = "A script to dump npc spawn locations.", logo = "", name = "Npc Spawn Dump", version = 1.0) public class NpcDumpScript extends Script { /** * A cached list of the npcs, to keep from dumping multiple NPC's of the same reference. */ ArrayList<NPC> cachedNpcs = new ArrayList<NPC>(); @Override public int onLoop() throws InterruptedException { for(NPC npc : this.getNpcs().getAll()) { if(!cachedNpcs.contains(npc)) { addNpcToDump(npc); } } return 600; } /** * Add an npc to the file & cache it. * @param npc */ public void addNpcToDump(final NPC npc) { try { this.logger.log(MessageType.INFO, "Dumping Npc: " + npc.getId() + " Loc: " + npc.getPosition().getX() + "," + npc.getPosition().getY()); File file = new File("npc_spawns.txt"); if(!file.exists()) file.createNewFile(); BufferedWriter writer = new BufferedWriter(new FileWriter(file, true)); writer.newLine(); writer.write(npc.getId() + " " + npc.getPosition().getX() + " " + npc.getPosition().getY()); writer.flush(); writer.close(); cachedNpcs.add(npc); } catch (Exception e) { this.logger.error("ERROR dumping npc spawn for: " + npc.getId() + " Loc: " + npc.getPosition().getX() + "," + npc.getPosition().getY()); e.printStackTrace(); } } } JAR Download(open source): http://kinztech.com/downloads/scripts/NpcDumpScript.jar Enjoy EDIT: It will stay updated here: https://github.com/kinztechcom/OSBot/blob/master/src/com/kinztech/scripts/npcdump/NpcDumpScript.java
  15. Looking so good, glad you're dedicated to pushing these updates weekly
  16. Dam some people can be such asses that's the os community for you.
  17. Allen

    Behold...

    I still need to watch the first two lol. A lot or my friends who I wouldn't expect to like it said that they did, so I expect to enjoy them too.
  18. Looks really interesting I'm exciting to see their development.
  19. RIP to all those banned. It'd be smart if the bot noticed the announcements and took precautions.
  20. Whatever gold the bot has on it is donated to the well.
  21. It's weird, he walked up to to chins, gave another mod the usernames, and the other mod searched them and said "yea theyre botting" Either its detected or they're just guessing lol.
  22. Well it got me into programming(private server) at a very young age so I guess that's a big thing that Runescape has taught me or motivated me towards.
  23. I wish we, as a community, could develop ways to change that.
×
×
  • Create New...