Jump to content

Woody

Members
  • Posts

    715
  • Joined

  • Last visited

  • Feedback

    100%

Posts posted by Woody

  1. First thing we need is an instance that supplies the methods we need (from MethodProvider). We can do this by extending upon the API type:
    final class DefaultAPI extends API {
    
    }

    You will be forced to declare an initializeModule method. Don't worry about it, just the devs not following interface segregation wink.png Leave it blank. You could fill it in, but you would be required to call it after instantiating API. 

     

    Once you have your API type, create an instance of it in onStart in your Script subclass:

    final class MyScript extends Script {
        private API api;
    
        public void onStart() {
            api = new DefaultAPI();
    
        }
    }

    Finally, we need to pass the context of our script to our api instance. We do this by calling exchangeContext on our api instance, passing in the script's bot:

    final class MyScript extends Script {
        private API api;
    
        public void onStart() {
            api = new DefaultAPI();
            api.exchangeContext(getBot());
    
        }
    }

    I quoted fixthissite's post. Read it through thoroughly and if you pay attention, you'll make it.

     

    Edit: If you did all of this above, here is an example:

    import org.osbot.rs07.api.model.Item;
    import org.osbot.rs07.script.API;
    
    
    public class Inventory {
    
        // ADDED THIS HERE @@@
        private API api;
    
        public Inventory(API api) {
            this.api = api;
        }
        // @@@@@@@
    	
        // WARNING: Untested code
        
        /** Holds the amount of willows we have cut */
        private int willowsCut = 0;
        /** Holds the last inventory that was compared */
        private Item[] lastInv;
        
        /**
         * Simple getter
         * @return the number of willows cut
         */
        public int getWillowsCut() {
            return willowsCut;
        }
        
        /**
         * Compares your last inventory with the current inventory.
         */
        public void compareItems() {
            if (lastInv == null) {
                lastInv = api.getInventory().getItems();
                return; // It will be the same, no need to check
            }
            
            String item = "Willow logs";
            Item[] currInv = getInventory().getItems();
            for (int i = 0; i < 28; i++) {
                // Check for the same thing
                if ((currInv[i] == null && lastInv == null)
                        || currInv[i].getName().equals(lastInv[i].getName()))
                    continue; // Its the same, continue
                
                if (currInv[i] != null) {
                    // We have an item when we didn't
                    if (currInv[i].getName().equals(item))
                        willowsCut++; // It was a willow log, ++
                } else {
                    // We don't have an item when we did
                    if (lastInv[i].getName().equals(item))
                        willowsCut--; // It was a willow log, --
                }
            }
            lastInv = currInv; // Update the inv
        }
        
        /**
         * Run this when the lastInv needs refreshing, aka after banking
         */
        public void resetItems() {
            lastInv = api.getInventory().getItems();
        }
    }
    

    If you want to get inventory in your Inventory class, simply do "api.getInventory()".

  2.  

    i have no clue how this works.... 

    	  	Inv invent = new Inv();
    	  	Inv.this.exchangeContext(bot);
    	  	invent.compareItems();
    	  	banked = invent.getWillowsCut();
    
        private MethodProvider api;
    
        public void onStart() {
            api = new Inv();
            api.exchangeContext(getBot());
    
        }
    
    
    did it in my class still null class called Inv en main class called main

     

    Read the guide and do it step by step.

  3. i know what a try catch is i always use it i just forgot for that one tongue.png

     

    can you send me a example with a filter please? never did that before

    Dude, I am suggesting to NOT use try & catch like how you are using it.

     

    Try something like this:

    RS2Object tree = getObjects().closest(new Filter<RS2Object>() {
    
    			@Override
    			public boolean match(RS2Object obj) {
    				return obj.getPosition().equals(WILLOW_POSITION_1) || obj.getPosition().equals(WILLOW_POSITION_2);
    			}
    			
    });
    

    then check if tree != null and do action. 

     

    Play around with it and learn how to use filters; it will help you A LOT when using filters.

    • Like 1
  4. Make a filter to only get the 2 desired willow trees. I would not recommend using a for loop like you did.

     

    Btw, do you know what try & catch is for? If not, read it up and you'll then understand why you don't have to use it like you are now.

  5. If you fixed it, then great.

     

    However, why are you a for loop here?

    for (int i = 0; i < Willow.length; i++) {   // why?
    			    	    
    }	
    

    Also, you don't really need to try and catch when doing an action. Just make sure the object is not null.

    • Like 1
  6. Yes its working fine now i just did allot of new coordinates sounds stupid but works perfectly now smile.png

     

    Btw how can i get my script in OSBot and how can i put message on debug console ohmy.png

    There's a section for script upload request.

     

    Use log(message) in your script for console debug.

    • Like 1
  7.  new Position(3999 , 3239 , 0),
    

    you sure this is correct?

     

     

    @Mocro, 

     

    this was your issue as Flamezzz posted. Look at the big difference in x coordinate.

     

    Edit: Use WalkingEvent. If you don't want it to click on the main screen, use WalkingEvent#setMiniMapDistanceTreshold. Incase you don't know how to use it, do some small tests and hopefully you'll get it.

  8.                 if(myPlayer().getInteracting() != null) {
                    NPC npc = npcs.closest(npc_name);
                    if (npc != null && npc.isVisible()) {
                        if (hoverEntityOption(npc, "Attack")) {
                            if (myPlayer().getInteracting() != npc) {
                                if (npc.isVisible()) {
                                    npc.interact("Attack");
                                    log("Attacking " + npc_name);
                                    sleep(random(400, 800));
                                } else {
                                    camera.toEntity(npc);
                                }
                            }
                        }
                    }
                }else {
                    if(menu.isOpen()) {
                        if(mouse.click(false)) {
                            for(int i = 0; i < 100 && !myPlayer().isUnderAttack(); i++) {
                                sleep(random(20,40));
                            }
                        }
                    } else {
                        if(npc != null && npc.isVisible()) {
                            if(npc.interact("Attack")) {
                                for(int i = 0; i < 100 && !myPlayer().isUnderAttack(); i++) {
                                    sleep(random(20,40));
                                }
                            }
                        } else if(npc != null && !npc.isVisible()) {
                            camera.toEntity(npc);
                        } else {
                            log(npc_name + " gone?");
                        }
                    }
                }
    

    I'm having trouble implementing your method.

     

    What am I doing wrong? The script keeps logging "npc_name gone?"

     

    Don't use the method of how to attack a goblin, that was just an example. There are plenty of other tutorials which can help you more. This snippet is meant for those who knows java.

  9.  

    Haha...you aren't too bright bud.

     

    Not once did I say I know you, but by what you are saying you can tell that you don't have much size an aren't very lean otherwise you would know first had that once you reach a certain level of physique no matter what you will get accused of steroids, an in some places its worse then others, like Sweden.

     

    Again....Not sure what my username has to do with anything, but if by "wannabe" lifter you mean Men's Physique competitor then ya brother I'm a hardcore "wannabe" lifter. Haha

     

    Watever makes you feel good about yourself bud.

     

    I do need to quote it 4 times....This explains why nobody accuses you of steroids. biggrin.png

     

    what. the. fuck.

     

    what are you talking about dude? 

  10. Yes, if you had any size and were lean then you would know first hand that people just look at you an assume you are on steroids when you have achieved a certain Physique, its just how the narrow minded individuals brain works. Some places are worse then others... for example Sweden.

     

    Not sure what my username has to do with anything but thanks for the compliment buddy.

     

     

    First of all, you don't have to quote my posts 4 times.

     

    Second, you are saying I have no size? Wow, you know a lot about me. facep.gif

     

    Third, take a look at your username, brah. 4844a010361bb4b4fb35efe6a395e980.png Wanna be lifter much? I think so.ODGXmfS.gif

  11. I live in the country, i know what i'm talking about. If you look at the more popular gym in Sweden, they have a chain of the same gym in different areas in Sweden. Just by looking at their terms and conditions, it clearly states in Swedish ''If we suspect you of illegal drug use, we expect negative test results by a doctor within a month'' 

     

    They claim they have that right and you basically agree to it when you sign up. Perhaps it's different where you live, or the guys are smart and only train during the middle of the night when the staff is gone and few people are there.

    Jag är kanske också från sverige..

    In Sweden he's right, happen's all the time , they take it very serious. That's great you have been going to the gym for 3 years, just because that it hasn't happen to you on a consistent basis doesn't mean it doesn't happen to other people. You have been in the gym for 3 years an obviously still aren't very big if you haven't come across issue's like this yourself, or you just haven't been to many different gym's.

    Hahah dude... are you for real?

     

    I know they take it serious. I am from Sweden. And you are saying I am not big because the cops has not asked me to piss in a cup, how dumb are you?

     

    They do not suspect all big bulky guys. The cops who does this have knowledge in training and steroid. They know who to look for.

     

    Cute username btw.

    Edit: The thing is, OP is acting like he got a real problem with this. He probably saw a raid in his gym and they took a couple of guys, and suddenly he's saying "dont come to sweden if you lift".

     

    The police do sometime check the gyms, and all gym have strict rules, but dont be fooled.

  12. Actually they do, it's happened on a few occasions. One guy who was out in public was interrogated by cops just for the way he looked. Another one who was in a restaurant and the waitress called the cops because he looked big. They will go to your apartment to find the drugs, it's happened before. All the good gyms have a deal with an association that is against steroids, so when you sign a membership, you basically agree to that. I have gone to an old school gym that's been around since the 70's and even they have that deal. I have seen massive guys there, then all of a sudden they're gone. 

    Lol actually...

     

    You see cops talking to a big guy and you instantly think they are accusing him for steroid use? That is pretty dumb of you. He is most certainly talking to the cops because they suspect him for stealing for instance or something like that.

     

    Don't come with false info dude, I've been going to the gym 3 years, 4-5 days a week and I have only seen undercover police ONCE 

  13. The cops do approaches as well in public if they suspect you, it's called ''Muscle profiling''. 

    Wtf?! No, they don't...

     

    When they look for steroid users, they do a raid in the gym and that does not happen that often. But shitty gyms with shitty people can get raided more often. 

  14. I watched my script kWarriors for 30 minutes, no noticeable issues with the NPC interactions. Do you have any specific entities that you would like me to test on (that doesn't require any crazy quests to get to)?

    Try bigger monsters, perhaps monsters with uneven contour like dragons for instance.

×
×
  • Create New...