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.

Can anyone help me

Featured Replies

Hey guys, I'm trying to learn Java, and script writing. I've been reading some tutorials and I just wrote this SUPER basic first script, however, it does NOTHING. I'm wondering if anyone can tell me where I went wrong, and why it does not attack "Chickens"

 

	import org.osbot.rs07.api.model.RS2Object;
import org.osbot.rs07.script.Script;
import org.osbot.rs07.script.ScriptManifest;
 
import java.awt.*;
import java.lang.Thread.State;
 
@ScriptManifest(author = "MySQLi", info = "Basic Chicken Killer", name = "MyChickenKiller", version = 1.0, logo = "")
public class Main extends Script {
 
    @Override
    public void onStart() {
        log("Thank you for using my script, Let's kill chickens!");
        
    }
    //What are we going to do in our script
    private enum State{
        KILL,WAIT
    };
    
    //Declare our conditions
    private State getState(){
        RS2Object chicken = getObjects().closest("Chicken");
        if(chicken != null)
            return State.KILL;
        return State.WAIT;
    }
    
    @Override
    public int onLoop() throws InterruptedException {
        switch (getState()){
        case KILL:
        RS2Object chicken = getObjects().closest("Chicken");
                if(chicken != null) {
                    chicken.interact("Attack");
                }
                break;
        case WAIT:
            sleep(random(500, 700));
            break;
            
        }
        return random(200, 300);
    }
 
    @Override
    public void onExit() {
        log("Thanks for running my Chicken Killer!");
    }
 
    @Override
    public void onPaint(Graphics2D g) {
 
    }
 
}
	

@MySQLi

Pretty sure its because you're using Objects. Read this guide: 

 

Use Entity & getNpc.

Entity chicken = getNpcs().closest("Chicken");

 

Edited by Phaibooty

just use onLoop bro

    @Override
    public  int onLoop() throws InterruptedException {
        if (!getCombat().isFighting() || myPlayer().getInteracting() == null){ //if not fighting or get interacting does not exist
            //NPC npc = getNpcs().closest("Chicken"); basic
            NPC npc = getNpcs().closest(new Filter<NPC>() { //filter api
                @Override
                public boolean match(NPC npc) {
                    return npc.hasAction("Attack") && npc.getName().equals("Chicken") && npc.getHealthPercent() > 0 && npc.getInteracting() == null;
                }
            });
            if (npc != null && npc.interact("Attack")) {
                new ConditionalSleep(2000) { //timout time. once 2000ms passes it will stop
                    @Override
                    public boolean condition() throws InterruptedException {
                        return getCombat().isFighting() || !npc.isAttackable(); //sleep until WE ARE FIGHTING OR WE CANT ATTACK THE NPC <- our condition true? stop sleeping :false sleep until 2000ms
                    }
                }.sleep();
            }
        } /// else we sleep the looptime.
      	return 600;
    }
                                                                                                                                           |

https://osbot.org/api/org/osbot/rs07/api/filter/Filter.html

https://osbot.org/api/org/osbot/rs07/api/model/Character.html

https://osbot.org/api/org/osbot/rs07/api/Combat.html

https://osbot.org/api/org/osbot/rs07/utility/ConditionalSleep.html

1 minute ago, Chris said:

just use onLoop bro


    @Override
    public  int onLoop() throws InterruptedException {
        if (!getCombat().isFighting() || myPlayer().getInteracting() == null){ //if not fighting or get interacting does not exist
            //NPC npc = getNpcs().closest("Chicken"); basic
            NPC npc = getNpcs().closest(new Filter<NPC>() { //filter api
                @Override
                public boolean match(NPC npc) {
                    return npc.hasAction("Attack") && npc.getName().equals("Chicken") && npc.getHealthPercent() > 0 && npc.getInteracting() == null;
                }
            });
            if (npc != null && npc.interact("Attack")) {
                new ConditionalSleep(2000) { //timout time. once 2000ms passes it will stop
                    @Override
                    public boolean condition() throws InterruptedException {
                        return getCombat().isFighting() || !npc.isAttackable(); //sleep until WE ARE FIGHTING OR WE CANT ATTACK THE NPC <- our condition true? stop sleeping :false sleep until 2000ms
                    }
                }.sleep();
            }
        } /// else we sleep the looptime.
      	return 600;
    }
                                                                                                                                           |

https://osbot.org/api/org/osbot/rs07/api/filter/Filter.html

https://osbot.org/api/org/osbot/rs07/api/model/Character.html

https://osbot.org/api/org/osbot/rs07/api/Combat.html

https://osbot.org/api/org/osbot/rs07/utility/ConditionalSleep.html

How're we going to piss off @Explv if we do that :feels: 

Edited by HeyImJamie

28 minutes ago, MySQLi said:

Hey guys, I'm trying to learn Java, and script writing. I've been reading some tutorials and I just wrote this SUPER basic first script, however, it does NOTHING. I'm wondering if anyone can tell me where I went wrong, and why it does not attack "Chickens"

 

  • Author

Thanks guys, I now have a basic chicken killer script running, I will now use this to build off and learn, appreciate the help!

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.