Jump to content
View in the app

A better way to browse. Learn more.

OSBot :: 2007 OSRS Botting

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

return isnt working properly??

Featured Replies

hello everyone

 

im trying to write my first script basicly a sandcrab training script.

now is my problem this:

NPC SC = npcs.closest("Sand Crab");
    RS2Object BC = getObjects().closest("Bank chest");
    Position MP = myPosition();


    if (!CT.contains(MP) && getInventory().contains("Salmon")) {
        log("Combat Area is empty walking to there now");
        getWalking().webWalk(CT);
    } else if (myPlayer().getHealthPercent() < 35) {
        log("Health below 35% eating Salmon");
        getInventory().interact("Eat", "Salmon");
    } else if (CT.contains(SC) && SC != null && !myPlayer().isAnimating()) {
        log("Attacking Sand Crab");
        SC.interact("Attack");
        sleep(50);
    } else if (!myPlayer().isAnimating() && SC == null) {
        log("resetting Agro");
        getWalking().webWalk(RSA);
    } else if (!getInventory().contains("Salmon")) {
        log("No food found in inventory checking bank");
        getWalking().webWalk(BT);
        if (BT.contains(MP)) {
            BC.interact("Use");
            sleep(2000);
        }
        if (getBank().contains("Salmon")) {
            getBank().withdrawAll("Salmon");
        } else if (!getBank().contains("Salmon")) {
            log("No food to be found please restock");
            stop();
        }
    }

    return random(3000, 60000);
}

it takes ages to get the log the attack even so long that it will log me out it

also wont move to RSA when he supposed to (if we dont have agro or !myPlayer().isAnimating())

 

this is all in onLoop()

 

am i missing something or ....

 

this is what comes from the logger

[INFO][Bot #1][09/14 09:37:23 PM]: Attacking Sand Crab
[INFO][Bot #1][09/14 09:41:16 PM]: Attacking Sand Crab

 

clearly its more then 1 minute

 

thanks in advance:D

 

Edited by lucune
Logger log

  • hellcatz changed the title to return isnt working properly??

So, a few problems. I'll go in order of least important to most important:

(1) Your code is prone to null pointer exceptions:

CT.contains(SC) && SC != null

Switch this to check if the object is null first. You should do this for all of your code. 

(2)

      (a) The sand crab is quite possibly also not in range. If you're not currently fighting the sand crab, somebody else probably is. How far away are the sand crabs you're trying to interact with? My guess is that they're reasonably far, or not easily visible.

       (b) Similarly, Sand crabs aren't actually NPCs until you turn them agro by standing beside them. You'll only attack a sand crab if it's already up and around.

(3) You sleep for up to an entire minute in between even checking the actions, totally tossing aside actually doing them.

return random(3000, 60000);

Make this wayyyy less. There are very few scenarios where it would actually make sense to have a gap this big, and this is not one of them.

(4) Please look into a state-based system. There are quite a few tutorials on it in the tutorials section. It'll make the code a lot easier to follow when you/others debug. Similarly, revise your variable names if you want others to be able to read your code. I don't know what CT, RSA, or BT are. 

 

Side note: This should reset agro anytime there isn't an active sand crab around you, given you have >= 35% HP, and have Salmon/are in some area CT. 

Edited by Team Cape

  • Author

thanks for the reply`s i scrapt it and restarted it with state`s 

Create an account or sign in to comment

Recently Browsing 0

  • No registered users viewing this page.

Account

Navigation

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.