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.

Constant NPE? Need help

Featured Replies

Issue


dc0f127a88.png


 


Code Source



package me.sinatra.machine.Activities;
import me.sinatra.machine.util.Activity;
import org.osbot.rs07.api.filter.Filter;
import org.osbot.rs07.api.model.NPC;
import org.osbot.rs07.script.Script;

/**
* Created by Sinatra on 8/5/2015.
*/
public class attackTarget implements Activity {
@Override
public boolean shouldDoActivity(Script s) {
return ((!s.myPlayer().isAnimating()) && (s.myPlayer().isVisible()) && (!s.myPlayer().isUnderAttack()));
}

@Override
public int doActivity(Script s) throws InterruptedException {
final NPC cow = s.npcs.closest(new Filter<NPC>() {
@Override
public boolean match(NPC npc) {
return npc != null && npc.getName().equals("Cow") && !npc.isUnderAttack() && npc.getHealth() > 0 && s.map.canReach(npc);
}
});
if (!cow.isVisible() || (cow == null)) {
s.camera.toEntity(cow);
s.sleep(s.random(2000));
} else {
cow.interact("Attack");
s.sleep(s.random(300)+3000);
}

return (s.random(500,2000));
}
}

Need help :)


You are doing !cow.isVisible before checking if cow is null.

Change

if(!cow.isVisible() || cow == null)

to

if(cow == null || !cow.isVisible())

Edited by fixthissite

 

Issue

dc0f127a88.png

 

Code Source

            s.camera.toEntity(cow);

 

 

from reading the line ref, the npe points to here. you're trying to turn the camera to a null cow hence the npe! :)

  • Author

ahh hot damn folks! Sinatra scripter noob did it again! thanks again!

In this line:

 if (!cow.isVisible() || (cow == null)) {

You're saying if the cow doesn't exist OR it isn't visible, move the camera.

Change to:

if (cow != null) {
    if (!cow.isVisible()) s.getCamera().toEntity(cow);
    cow.interact("Attack");
}

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.