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.

Script not functioning as intended

Featured Replies

None of this is happening. Why?

 

 
Edited:
@Override
    public int onLoop() throws InterruptedException {
        
        
        if (ClanWarsChest.contains(myPlayer())) {
            
            log("At banking area");
            
            if (!getInventory().onlyContains("Jug of wine")) {
                if (bank.isOpen()) {
                    bank.depositAll();
                    sleep(random(250, 350));
                    bank.withdrawAll("Jug of wine");
                    sleep(random(300, 500));
                    bank.close();
                } else {
                    bank.open();
                }
            } else if (portalArea.contains(myPlayer())) {
                
                log("At portal area");
                
                if (objects.closest("Free-for-all portal") != null) {
                    camera.toEntity(objects.closest("Free-for-all portal"));
                    objects.closest("Free-for-all portal").interact("Enter");
                }
            } else if(portalSpawnArea.contains(myPlayer())){
                walking.walk(combatArea);
            }
            
            else {
                walking.walk(portalArea);
            }
        } else if (combatArea.contains(myPlayer())) {
            log("At combat area");
            if (getInventory().contains("Jug of wine")) {
                if (getSkills().getStatic(Skill.HITPOINTS) - getSkills().getDynamic(Skill.HITPOINTS) > 11) {
                    getInventory().getItem("Jug of wine").interact("Drink");
                    log("Healing");
                }
            }
        }


        return random(100, 200); //The amount of time in milliseconds before the loop starts over
    }

Drinking works.

Edited by sampla

 

None of this is happening. Why?

 

 

 

 

@Override
    public int onLoop() throws InterruptedException {
        Player player = myPlayer();
        
        if (area1.contains(player)) {
            
            log("At area1");
            
            if (!getInventory().onlyContains("item")) {
                if (bank.isOpen()) {
                    bank.depositAll();
                    sleep(random(250, 350));
                    bank.withdrawAll("item");
                    sleep(random(300, 500));
                    bank.close();
                } else {
                    bank.open();
                }
            } else if (area2.contains(player)) {
                
                log("At area2");
                
                if (objects.closest("object") != null) {
                    camera.toEntity(objects.closest("object"));
                    objects.closest("object").interact("action");
                }
            } else if(area3.contains(player)){
                walking.walk(area3);
            }
            
            else {
                walking.walk(area2);
            }
        } else if (area3.contains(player)) {
            log("At area3");
 
 
the part after this is working.

 

 

In the future, when posting to the scripting help section, please use the code tags. It is the blue button that looks like: < >

 

Are you sure your player is in one of those areas?

 

What is the code after, that does work?

don't make an instance of myplayer :p

 

area.contains(myPlayer())

 

does it do anything else , or just that onloop ?

Edited by The Hero of Time

don't make an instance of myplayer :p

 

area.contains(myPlayer())

 

does it do anything else , or just that onloop ?

 

He didn't make an instance of Player, he just stored it. That's not the issue

He didn't make an instance of Player, he just stored it. That's not the issue

just a suggestion, not a fix. 

 

what purpose does it have in myplayer's case?

  • Author

don't make an instance of myplayer :p

 

area.contains(myPlayer())

 

does it do anything else , or just that onloop ?

Edited to show the whole thing.

 

In the future, when posting to the scripting help section, please use the code tags. It is the blue button that looks like: < >

 

Are you sure your player is in one of those areas?

 

What is the code after, that does work?

Edited it to show the whole thing, I don't care.

I got the banking area from the snippets here.

Edited by sampla

None of this is happening. Why?

 

 
Edited:
@Override
    public int onLoop() throws InterruptedException {
        
        
        if (ClanWarsChest.contains(myPlayer())) {
            
            log("At banking area");
            
            if (!getInventory().onlyContains("Jug of wine")) {
                if (bank.isOpen()) {
                    bank.depositAll();
                    sleep(random(250, 350));
                    bank.withdrawAll("Jug of wine");
                    sleep(random(300, 500));
                    bank.close();
                } else {
                    bank.open();
                }
            } else if (portalArea.contains(myPlayer())) {
                
                log("At portal area");
                
                if (objects.closest("Free-for-all portal") != null) {
                    camera.toEntity(objects.closest("Free-for-all portal"));
                    objects.closest("Free-for-all portal").interact("Enter");
                }
            } else if(portalSpawnArea.contains(myPlayer())){
                walking.walk(combatArea);
            }
            
            else {
                walking.walk(portalArea);
            }
        } else if (combatArea.contains(myPlayer())) {
            log("At combat area");
            if (getInventory().contains("Jug of wine")) {
                if (getSkills().getStatic(Skill.HITPOINTS) - getSkills().getDynamic(Skill.HITPOINTS) > 11) {
                    getInventory().getItem("Jug of wine").interact("Drink");
                    log("Healing");
                }
            }
        }


        return random(100, 200); //The amount of time in milliseconds before the loop starts over
    }

Drinking works.

and it doesn't do

log("At banking area");
?
  • Author

 

and it doesn't do

log("At banking area");
?

 

Nope. I guess it doesn't find the player then.

  • Author

Mapped two areas using Explv's map. No change.

Mapped two areas using Explv's map. No change.

 

Well the only reason that log statement wouldn't work is if your player is not in the area.

 

Feel free to pm me in the chatbox and I can take a look over teamviewer

  • Author

Well the only reason that log statement wouldn't work is if your player is not in the area.

 

Feel free to pm me in the chatbox and I can take a look over teamviewer

I made a new script that only logs the area. Banking, portal and spawn areas were fine.

None of this is happening. Why?

 

 
Edited:
@Override
    public int onLoop() throws InterruptedException {
        
        
        if (ClanWarsChest.contains(myPlayer())) {
            
            log("At banking area");
            
            if (!getInventory().onlyContains("Jug of wine")) {
                if (bank.isOpen()) {
                    bank.depositAll();
                    sleep(random(250, 350));
                    bank.withdrawAll("Jug of wine");
                    sleep(random(300, 500));
                    bank.close();
                } else {
                    bank.open();
                }
            } else if (portalArea.contains(myPlayer())) {
                
                log("At portal area");
                
                if (objects.closest("Free-for-all portal") != null) {
                    camera.toEntity(objects.closest("Free-for-all portal"));
                    objects.closest("Free-for-all portal").interact("Enter");
                }
            } else if(portalSpawnArea.contains(myPlayer())){
                walking.walk(combatArea);
            }
            
            else {
                walking.walk(portalArea);
            }
        } else if (combatArea.contains(myPlayer())) {
            log("At combat area");
            if (getInventory().contains("Jug of wine")) {
                if (getSkills().getStatic(Skill.HITPOINTS) - getSkills().getDynamic(Skill.HITPOINTS) > 11) {
                    getInventory().getItem("Jug of wine").interact("Drink");
                    log("Healing");
                }
            }
        }


        return random(100, 200); //The amount of time in milliseconds before the loop starts over
    }

Drinking works.

 

I think that your portal area checks should not be inside the bank area check.

 

Perhaps if you cleaned up the script a bit, you could more easily identify the issues:

import org.osbot.rs07.api.map.Area;
import org.osbot.rs07.api.ui.Skill;
import org.osbot.rs07.script.Script;
import org.osbot.rs07.script.ScriptManifest;
import org.osbot.rs07.utility.ConditionalSleep;

@ScriptManifest(author = "Explv", name = "Wine Drinker", info = "Drinks Wine", logo = "", version = 0.1)
public class WineDrinker extends Script {

    private enum State { BANKING, DRINKING, WALKING_TO_BANK, WALKING_TO_PORTAL, WALKING_TO_COMBAT, TELEPORTING }
    
    private final Area portalArea = new Area(0, 0, 0, 0),
                       bankArea   = new Area(0, 0, 0, 0),
                       spawnArea  = new Area(0, 0, 0, 0),
                       combatArea = new Area(0, 0, 0, 0);
    
    @Override
    public int onLoop() throws InterruptedException {
        switch (getState()){
            case BANKING:
                bank();
                break;
            case DRINKING:
                drink();
                break;
            case WALKING_TO_BANK:
                getWalking().webWalk(bankArea);
                break;
            case WALKING_TO_PORTAL:
                getWalking().webWalk(portalArea);
                break;
            case WALKING_TO_COMBAT:
                getWalking().webWalk(combatArea);
                break;
            case TELEPORTING:
                teleport();
                break;
        }
        return random(200, 300);
    }
    
    private State getState() {
        if(!getInventory().contains("Jug of wine")){
            return bankArea.contains(myPosition()) ? State.BANKING : State.WALKING_TO_BANK;
        }
        if(spawnArea.contains(myPosition())) return State.WALKING_TO_COMBAT;
        if(combatArea.contains(myPosition())) return State.DRINKING;
        return portalArea.contains(myPosition()) ? State.TELEPORTING : State.WALKING_TO_PORTAL;
    }
    
    private void teleport(){
        if(getObjects().closest("Free-for-all portal").interact("Enter")){
            new ConditionalSleep(5000) {
                @Override
                public boolean condition() throws InterruptedException {
                    return !portalArea.contains(myPosition());
                }
            }.sleep();
        }
    }
    
    private void bank() throws InterruptedException {
        if(!getBank().isOpen()) {
            openBank();
        } else if(!getInventory().isEmptyExcept("Jug of wine")) {
            getBank().depositAllExcept("Jug of wine");
        } else if(!getInventory().contains("Jug of wine")){
            if(getBank().contains("Jug of wine")) getBank().withdrawAll("Jug of wine");
            else stop();
        }
    }
    
    private void openBank() throws InterruptedException {
        if(getBank().open()){
            new ConditionalSleep(5000) {
                @Override
                public boolean condition() throws InterruptedException {
                    return getBank().isOpen();
                }
            }.sleep();
        }
    }
    
    private void drink() {
        if (getSkills().getStatic(Skill.HITPOINTS) - getSkills().getDynamic(Skill.HITPOINTS) > 11) {
            getInventory().getItem("Jug of wine").interact("Drink");
        }
    }
}

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.