Jump to content

[Beginner] How to withdraw an item from bank based on the condition that a skill is equal or above or/and under a certain level? :)


t0r3

Recommended Posts

47 minutes ago, Xx pk xX said:

while (getDialogues().isPendingContinuation() || getDialogues().isPendingOption())
{
	getDialogues().clickContinue();
	getDialogues().completeDialogue("Option you want to click if there are more options", "another options to click", "another option...");
}

If you want to just click continue (e.g. you don't have to choose an option while talking to a NPC), and you are expecting only "Click here to continue" then:


while (getDialogues().isPendingContinuation())
{
    if (getDialogues().clickContinue())
    {
     	//click fishing spot again                                   
    }
}

Put above code somewhere where you are using sleep condition while your player is fishing (e.g. after/before checking your player.isAnimating() method)

For bank depositing just use getBank.deposit methods. I believe widgets are used in banking methods like deposit, withdraw, etc, but you don't need to worry about that. Just use OSBot banking API, and you should be fine (unless you need something really special that's not covered in API).

Thank you so much, helping me alot! :D 

Guessing I could use this for questing too? Might be a better method though idk :o 

As for sleep, I am just using ' sleep(random()); ' at the moment, not used to conditional sleep yet.

Put it in like this, - what do you think?

// Fishing code

NPC fishingSpot = getNpcs().closest("Fishing spot");

if(fishingSpot != null && !myPlayer().isAnimating() && !myPlayer().isMoving()){

    while (getDialogues().isPendingContinuation()){

        log("Leveled up, clicking continue");
        getDialogues().clickContinue();

        if(getDialogues().clickContinue()){

            log("Interacting with fishingSpot again");
            fishingSpot.interact("Net");
        }
    }

    log("Interacting with fishingSpot");
    fishingSpot.interact("Net");

Is it possible to do this without ' if ' after clicking continue, - and also what type is ' getDialogues ' ? :D I want to declare a variable called Continueing :) Sry, am noob.

Thanks

EDIT:

- This might not work as myPlayer(); would still be isAnimating(); before going idle, then it would just fish again, making this pointless haha...hm. Should I put it somewhere else         maybe?

- Tested it again, aaand now my log just confirmed it clicking continue over and over again before going idle hmm

Edited by t0r3
Link to comment
Share on other sites

19 minutes ago, t0r3 said:

Thank you so much, helping me alot! :D 

Guessing I could use this for questing too? Might be a better method though idk :o 

As for sleep, I am just using ' sleep(random()); ' at the moment, not used to conditional sleep yet.

Put it in like this, - what do you think?


// Fishing code

NPC fishingSpot = getNpcs().closest("Fishing spot");

if(fishingSpot != null && !myPlayer().isAnimating() && !myPlayer().isMoving()){

    while (getDialogues().isPendingContinuation()){

        log("Leveled up, clicking continue");
        getDialogues().clickContinue();

        if(getDialogues().clickContinue()){

            log("Interacting with fishingSpot again");
            fishingSpot.interact("Net");
        }
    }

    log("Interacting with fishingSpot");
    fishingSpot.interact("Net");

 Is it possible to do this without ' if ' after clicking continue, - and also what type is ' getDialogues ' ? :D I want to declare a variable called Continueing :) Sry, am noob.

Thanks

 

Of course you could use something like this for quests

 if (getDialogues().isPendingOption()) getDialogues().completeDialogue("Option you want to click");

and for the rest:

        NPC fishingSpot = getNpcs().closest("Fishing spot");

        if(fishingSpot != null && !myPlayer().isAnimating() && !myPlayer().isMoving())
        {
            log("Interacting with fishingSpot");
          if (fishingSpot.interact("Net"))
            {
                //I'm not sure about exact conditions for fishing, but this should  work
                while ((myPlayer().isMoving() || myPlayer().isAnimating()) && fishingSpot.exists())
                {
                    //if  you want to click continue while you are fishing, then put this condition here
                    if (getDialogues().isPendingContinuation())
                    {
                        log("Leveled up, clicking continue");
                        //you don't need if condition here if there is no action you want to do after clicking continue
                        getDialogues().clickContinue();

                        //but you can do something like this
                        if (getDialogues().clickContinue() && fishingSpot.exists())
                        {
                            //click fish again after clicking dialog
                            fishingSpot.interact("Net");
                        }
                    }
                    sleep(MethodProvider.random(50, 500));
                }
            }
        }

 

Edited by Xx pk xX
Link to comment
Share on other sites

18 minutes ago, Xx pk xX said:

Of course you could use something like this for quests


 if (getDialogues().isPendingOption()) getDialogues().completeDialogue("Option you want to click");

and for the rest:


        NPC fishingSpot = getNpcs().closest("Fishing spot");

        if(fishingSpot != null && !myPlayer().isAnimating() && !myPlayer().isMoving())
        {
            log("Interacting with fishingSpot");
          if (fishingSpot.interact("Net"))
            {
                //I'm not sure about exact conditions for fishing, but this should  work
                while ((myPlayer().isMoving() || myPlayer().isAnimating()) && fishingSpot.exists())
                {
                    //if  you want to click continue while you are fishing, then put this condition here
                    if (getDialogues().isPendingContinuation())
                    {
                        log("Leveled up, clicking continue");
                        //you don't need if condition here if there is no action you want to do after clicking continue
                        getDialogues().clickContinue();

                        //but you can do something like this
                        if (getDialogues().clickContinue() && fishingSpot.exists())
                        {
                            //click fish again after clicking dialog
                            fishingSpot.interact("Net");
                        }
                    }
                    sleep(MethodProvider.random(50, 500));
                }
            }
        }

 

Got this to work :) 

 

// Fishing code

NPC fishingSpot = getNpcs().closest("Fishing spot");

while (getDialogues().isPendingContinuation()){

    if(getDialogues().clickContinue()){

        log("Interacting with fishingSpot again");
        fishingSpot.interact("Net");
    }
}

if(fishingSpot != null && !myPlayer().isAnimating() && !myPlayer().isMoving()){

    log("Interacting with fishingSpot");
    fishingSpot.interact("Net");

 

I put the While loop first, so that it checks before fishing. If no dialogue option it would just skip it :) and do usual fishing routine. I think.

Why are you using ' .exists ' though, instead of ' fishingSpot != null? It's not the same?

Thanks for helping :D

Link to comment
Share on other sites

6 minutes ago, t0r3 said:

Why are you using ' .exists ' though, instead of ' fishingSpot != null? It's not the same?

Thanks for helping :D

Calling .exists on an object that is null will still trow a nullpointerexception so you should check first if its not null.

Not null is just checking if you have it stored in memory, it will check if your reference is pointing to something.  Exists checks if it actually exists ingame (if i recall correctly)  though some objects might implement exists in another way. 

Edited by zwaffel
Link to comment
Share on other sites

4 minutes ago, t0r3 said:

@zwaffel So, what would be the point in using .exists? If so isn't .exists for an object always true, as it is always in game? Sry if that is a stupid question.. haha

From API:

public boolean exists()
Checks whether this Entity still exists or not.
Returns:
Whether this Entity still exists or not.

So for example you could call 

NPC fishingSpot = getNpcs().closest("Fishing spot");

First of all you need to check if it's not null. Calling exists() on null object will throw NullPointerException. Then you can do some actions.

However, after running some actions, e.g. interact, wait while animating etc. that fishing spot might "disappear" from RS, so calling if if(fishingSpot.exists()) returns true if the fishingSpot still exists in RS. 

So as @zwaffel said. Once you know it is not null, you are certain that object is stored in your memory. But as time pass, it will still be in your memory, but it might not exist in RS anymore. That's why you can always use exists() method as well to check that out.

 

Link to comment
Share on other sites

8 minutes ago, Nor3g said:

You need to get really autistic about what you're doing. Log into runescape and then very slowly note down everything you want to do. So the exact conditions that need to be met for you to perform an action, and then create if and else ifs for everything in the right priority.

Hahahaha yeah, already on my way! :D

Link to comment
Share on other sites

3 hours ago, Xx pk xX said:

From API:


public boolean exists()
Checks whether this Entity still exists or not.
Returns:
Whether this Entity still exists or not.

So for example you could call 


NPC fishingSpot = getNpcs().closest("Fishing spot");

First of all you need to check if it's not null. Calling exists() on null object will throw NullPointerException. Then you can do some actions.

However, after running some actions, e.g. interact, wait while animating etc. that fishing spot might "disappear" from RS, so calling if if(fishingSpot.exists()) returns true if the fishingSpot still exists in RS. 

So as @zwaffel said. Once you know it is not null, you are certain that object is stored in your memory. But as time pass, it will still be in your memory, but it might not exist in RS anymore. That's why you can always use exists() method as well to check that out.

 

Thanks, that clarified alot :D Love learning to script :) 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...