Jump to content

BravoTaco

Scripter II
  • Posts

    240
  • Joined

  • Last visited

  • Feedback

    100%

Everything posted by BravoTaco

  1. Sorry to hear that its not working for ya I will look into this.
  2. Thanks for the positive feedback. You should be able to start it from almost anywhere and it will walk to where it needs to.
  3. This is usually caused when using while loops wrong. Or if you are using more threads. Will need code to diagnose though.
  4. If ya do buy, than thank you. And lmk if you run into any problems.
  5. As of right now, probably not. I do not have the skill/quest requirements for the accounts to do so. I have been leveling up some accounts so I may in the future but not atm.
  6. Np. Let me know if ya have any questions.
  7. Don't worry about asking to many questions, that's how you learn. As stated though, learning java and its fundamentals would help greatly with this, but I will try to give some information and maybe help to point you in the right direction. As the current code stands the logic is this 1st -> You declare some variables. The Player variable, setting it to myPlayer() is unneeded and you and should just use myPlayer() when you want to access that particular object. Also with calling myPlayer(), since it is more than just a variable call, and is actually a method call, it could be doing more than just returning the variable itself. So when you set a Player variable with myPlayer() you may actually be using an older version of that Player object when you later call upon that variable. The same from above also applies to the Inventory object. The TARGET_AREA does not need to be a variable as you can just use the one that is passed in via the method parameters since the area does not change from the initial parameter value to the end result. Setting the playerArea variable is actually okay here, and is probably the only variable that I would create in this method. 2nd -> You than move onto the looting-loop. Right off the bat you mess up the for-loop which is fine again, you just need to learn the fundamentals of java. We've all been there Here is a link to for-loops to better help explain them. I will try to explain how the current one is wrong, and some things you could do to fix it. for(int i = 0; i < Item_Name.length; i++) In the line of code above, you are starting a for loop with i is equal to 0, and you will than loop as long as i is less than the string variables length, and increment 'i' each loop by one. The problem with this line of code is your conditional, which is the second statement "i < Item_Name.length". With this you are essentially setting the loop to run according to how many characters/letters there are in the string variable, and not actually setting the loop to run equal to how much loot there is to pick-up from the ground. To fix this you could declare the available loot before entering the for-loop and using the length/count from that array/list, in the conditional statement of your for-loop. List<GroundItem> loot = groundItems.filter(l -> l.getName().equals(Item_Name[i]) && playerArea.contains(l)); In the line of code above, you set the ground items you want to pick-up which is correct, but you are doing it every time you loop in the for-loop. I recommend moving this above the for-loop and than create the for loop to iterate through it. Here is a link to looping through lists/arrays. if(!inven.isFull() && TARGET_AREA.contains(player)) Moving further down in the for-loop we come across the first condition check. Which states if the players inventory is not full and the TARGET_AREA contains the player than return true. The first check pertaining to the inventory is good, and needed in this situation. The second check pertaining to the area check, is not needed and also not logically correct. What you need to be checking is if the GroundItem you are wanting to loot is within the TARGET_AREA not the player, otherwise you will have cases where even though the player is within the area, the loot may not be, and that can cause the player to loot items outside of the specified range. if (loot != null && loot.exists() &&loot.isVisible()) Good job doing a null check, those can be easily forgotten. But the function completely falls apart after this check. Since as you are not referencing just one item when you call the loot variable, but are actually referencing an entire list/array of them. This will be fixed if you refactor the code and move declaring the available loot before the for-loop and looping through that, which will return a single item from the list each loop. loot.interact("Take"); sleep(random(500,1000)); Again the loot variable is not just a single item and so the interact() will not work on it. The sleep should be a ConditionalSleep here is a link to those look under the sleep section. Hope this helps to clear some things up, If I made you more confused I am sorry for that I'm not the best at explaining things through text. Let me know if you have any questions.
  8. Do you mean skills in Java or in scripting? If you mean for scripting, I recommend just creating little scripts until you are able to flush out a well structured and well optimized one. After that try to create an AIO script that allows for user input to change the activities the script will do. I see that you used a UI designer to create your ConfigForm, which is okay but, I highly recommend you learn to create GUI's through code. Here is a link to a thread that will help with that - Explv's Scripting 101 section 16.
  9. Welcome. Any questions on scripting feel free to PM me.
  10. Not a bad script for a "small and ugly" one I've definitely seen worse, some that I have made . Keep it up you'll have scripting down in no time. Quick suggestion though. You should look into GitHub for when posting your Open Sources, its a version control system that will allow people to look at your code without having to download it, plus a bunch of other features for quicker development and a place that can store a backup of your scripts in-case your storage fails. Also most IDE's have an integrated system for pushing updates/projects to GitHub within the IDE itself. Let me know if you have any questions about scripting or GitHub.
  11. Np. Glad ya got it all figured out, lmk if you have any other questions.
  12. Not exactly. When the berries are picked from the bush, the bush's ID will stay the same but the children model ID of the berries are removed from the modelIDs array. It is possible to select a bush with an ID, you would just have to create a method that will loop through the bush's child IDs and if it contains the ID than return that bush an example of that would look like this. private RS2Object getObjectFromChildModelID(Predicate<RS2Object> filter, int childID) { Object[] objects = getObjects().getAll().stream().filter(filter).toArray(); for (Object o : objects) { if (o != null) { RS2Object rs2Object = (RS2Object) o; if (rs2Object != null && rs2Object.getModelIds() != null) { for (int id : rs2Object.getModelIds()) { if (id == childID) return rs2Object; } } } } return null; } I have not tested the above code, but lets talk about what I am doing. First I declare an Array of Objects that contains all objects that matches the given filter. Than I loop through all those Objects, null check them, and cast them to an RS2Object, I have to do this since when I was grabbing the objects they were stored as an Object and not an RS2Object. After casting it to an RS2Object, I can loop through the modelIDs and check if any of the children ID's match the given ID. If a match is found that it will return that object else it will return null. Also this code will not always return the closest bush, it will return whichever bush passes its condition check first. The code in action. Predicate<RS2Object> bushFilter = new Predicate<RS2Object>() { @Override public boolean test(RS2Object rs2Object) { return rs2Object.getName().equalsIgnoreCase("Redberry bush"); } }; RS2Object bush = getObjectFromChildModelID(bushFilter, -1); if (bush != null && bush.interact("Pick-from")) { // other code here. } First I declare a Predicate of type RS2Object for the filter. A Predicate is essentially the same thing as a Filter, but is Java's version of it. Than I try to set the bush variable using the above code snippet. The -1 would be whatever the ID of the berries is, you would have to do some investigating to find that. Lastly, I null check and than interact with the bush.
  13. Repetition is one the biggest things I've found that gets you banned. Try doing slayer one day than some other stuff the next day. I also limit the amount of time to about 2-3 hours a day. Even with the best code/task randomizing, you will still eventually get banned.
  14. RS2Object bush = getObjects().closest(o -> o.getName().endsWith("bush") && o.getModelIds().length > 1); Essentially what this is doing is applying a filter, using lambda expression. It will only grab the Object that passes the conditional check. This can also look like this. Filter<RS2Object> bushFilter = new Filter<RS2Object>() { @Override public boolean match(RS2Object rs2Object) { return rs2Object.getModelIds().length > 1 && rs2Object.getName().toLowerCase().endsWith("bush"); } }; RS2Object bush = getObjects().closest(bushFilter); With the above code I first create a Filter of type RS2Object, than pass it to the getObjects().closest() method. You can also cache this filter as a variable inside the class, so you won't have to declare it every time before using it. That would look something like this. public class OSBotScript extends Script { private final Filter<RS2Object> bushFilter = new Filter<RS2Object>() { @Override public boolean match(RS2Object rs2Object) { return rs2Object.getModelIds().length > 1 && rs2Object.getName().toLowerCase().endsWith("bush"); } }; With all that, lets break down what exactly is happening with the checks. First the getModelIds() call, when the bush has no berries on it the modelIds array will return a a length of 1 since it is only showing the bush model. But once there are berries on the bush, it will than have more than one modelId stored inside the array so the length of it will be greater than 1. The second call is just simply checking the name to see if the RS2Object does end with bush, you can change this to the exact name instead, that would look like this. private final Filter<RS2Object> bushFilter = new Filter<RS2Object>() { @Override public boolean match(RS2Object rs2Object) { return rs2Object.getModelIds().length > 1 && rs2Object.getName().equalsIgnoreCase("Redberry bush"); } }; If both conditions are true than it will return that RS2Object.
  15. Quick questions... How many hours per day did you bot for? Did you just do slayer all 5 days? Has an account been banned for botting on that IP/Proxy?
  16. You don't have to inverse the bool value in the first if statement just use != operator instead of ==, it will make it easier to read. Ex. - if (getInventory.getAmount("Redberries") != 3) You should also remove the for loop and allow the script to re-loop to re-trigger this action. I have found that scripts are much easier to debug/maintain if there is only 1 action happening per loop. When interacting with something you should wrap it in an if statement so you will only activate your sleep call if the interaction was successful. Ex. - if (redberries.interact("Pick-from")) Now for the problem of it not picking the required amount, that is down to the current logic of the script. If we take a look at this line RS2Object redberries = getObjects().closest("Redberry bush"); And than look at how you are using that variable for (int i=0; i<4; i++) { int berryCount = i; redberries.interact("Pick-from"); Sleep.sleepUntil(() -> getInventory().getAmount("Redberries") == berryCount + 1, 5000); } You can see that in the loop you are not updating the redberries variable to another available bush, so you are trying to pick berries from the same bush even though you have already picked from there. To fix that you would simply move where you set the variable to inside the loop, but again I don't recommend using for/while loops in scripts except for certain circumstances such as different dropping methods. Also you should always do a null check before using the variable. With the for loop, if i = 0 than, you would do i < 3, to perform an action 3 times, since i is starting at 0. No need to set berrycount == i, just use i. for (int i = 0; i < 3; i++) { RS2Object redberries = getObjects().closest("Redberry bush"); if (redberries != null) { if (redberries.interact("Pick-from")) { Sleep.sleepUntil(() -> getInventory().getAmount("Redberries") == (i + 1), 5000); } } } Let me know if you have any questions
  17. Your script manifest is in the wrong spot. And since OsBot uses that to identify your script it will not show up in the script selector. Place it above the class and all should be fixed.
  18. Np, feel free to PM me if you have any questions.
  19. Yeah exactly, the parameter name does not matter. Only the type, in this case Area, does.
  20. No need to worry about asking too many questions. That's how you learn You are just missing the parameter for the method. A parameter is placed in between the parenthesis after your method name, so it would look like this walk(Area x) In code. Also you don't need to use a sleep as the WebWalker will pause further execution of the script until the event is over. private void walk(Area x) { if (!x.contains(myPosition())){ getWalking().webWalk(x); } }
  21. BravoTaco

    please delete

    I can sell ya one. 41 attack, 41 Strength, 40 Defence, 77 fishing. PM me if interested.
  22. Wrong type of trading my friend.
  23. Yeah, the WebWalker will do a bunch of stuff to get from point A to point B. Take a look at WebWalkEvent in the API. Heres the link. WebWalkEvent API
  24. No need to create your own walking method. Use the WebWalker instead. getWalking().webWalk(Banks.LUMBRIDGE_UPPER); You can also give the WebWalker a Position, Position[], Area, or an Area[]. It will choose the closest destination if given an array.
  25. So as your script is right now, the logic goes as this. Finds nearest cow -> evaluates the if conditions -> attacks the cow -> sleeps until not in combat or 8000 milliseconds has passed -> re-loop after a random amount of milliseconds between 100, 300. With the logic written out I'll try to explain why its bugging out, and some things you could do to prevent those things. If you want to just see code and not an explanation of why or how it will be at the bottom of this reply. With that said I'll try to be as descriptive and informative as I can, but I'm not the best at explaining things through text. The issue with setting the NPC to attack is that you are setting it equal to a new NPC everytime the script loops regardless, if you are already in combat or not. Now this may just set it to the NPC you are fighting since it may be the closest, but that wont always be the case. To fix this, set the NPC to attack after you have checked to see if you are not already fighting something. For the interaction of the NPC it is exactly as @Protoprize wrote, you are not allowing the bot to wait after the interaction, and since the script is set to re-loop at a very quick interval, the max being 300 milliseconds, this can cause it to try to interact/spam click with other NPC's since it has not yet reached its target to start the combat. With the current sleep that is being applied after you call the interact() method it will almost always end the first time it evaluates the condition the first time, as it ends once you are not in combat, and since its only been a millisecond or even less since you called interact() you will almost never be in the combat state that quickly, as that is too quick even for Runescape to have sent the next update of the game world state. To fix this simply change your ConditionalSleep() after you call interact() and wait for the expected outcome. For a combat scenario you would wait until you are in-combat. There is more, but I believe if you modify your code with the above knowledge it will work without needing to modify anything else. If you have any questions or my post has left ya confused feel free to PM me, I'll try to answer as quick as possible. I wrote up a quick example script for attacking something, the code is below.
×
×
  • Create New...