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.

How to check if player in certain area?

Featured Replies

What's the code to check if my player is in a certain area and if it is to walk to another? Tried couple different things and couldn't get it to not error. Making a simple walking script for my first script and this is only problem i'm having so far.

if (area.contains(myPosition()) {
  getWalking.webWalk(newArea);
}

area being the area that your character is currently in, newArea being the place you want your character to be.

I reccomend using Explv's Map to make areas.

  • Author
4 hours ago, Lunar said:

if (area.contains(myPosition()) {
  getWalking.webWalk(newArea);
}

area being the area that your character is currently in, newArea being the place you want your character to be.

I reccomend using Explv's Map to make areas.

I tried that and it errors because of contains. But if for say I'm in lumbridge and I want it to check if I'm there can I just put if (area.contains(myPosition()) ? or do I need to define the area that I'm asking if it contains my player?

 

1 hour ago, SmaTTeR said:

 But if for say I'm in lumbridge and I want it to check if I'm there can I just put if (area.contains(myPosition()) ? or do I need to define the area that I'm asking if it contains my player?

 

You'd have to define the area. Explv's map makes it really easy to do that, I linked it in my previous reply.

1 hour ago, SmaTTeR said:

I tried that and it errors because of contains. But if for say I'm in lumbridge and I want it to check if I'm there can I just put if (area.contains(myPosition()) ? or do I need to define the area that I'm asking if it contains my player?

 

You need to define the area. And make sure it's the OSBot Area import and not the Java Area import.

  • Author

so...

Area[] lumbridgeSpawn = {
        new Area(3217, 3219, 3217, 3224),
        new Area(3217, 3226, 3226, 3212)
};

then

if (area.contains(myPosition()) {
  getWalking.webWalk(newArea);
}

would that be right?

 

And these are the imports I have...

import org.osbot.rs07.api.map.Area;
import org.osbot.rs07.script.Script;
import org.osbot.rs07.api.model.Player;
import org.osbot.rs07.api.Walking;
import org.osbot.rs07.script.ScriptManifest;
import java.awt.*;

Edited by SmaTTeR

  • 1 month later...
On 5/9/2021 at 3:15 PM, SmaTTeR said:

so...



Area[] lumbridgeSpawn = {
        new Area(3217, 3219, 3217, 3224),
        new Area(3217, 3226, 3226, 3212)
};

then



if (area.contains(myPosition()) {
  getWalking.webWalk(newArea);
}

would that be right?

 

And these are the imports I have...



import org.osbot.rs07.api.map.Area;
import org.osbot.rs07.script.Script;
import org.osbot.rs07.api.model.Player;
import org.osbot.rs07.api.Walking;
import org.osbot.rs07.script.ScriptManifest;
import java.awt.*;

why are you importing java.awt.*

i have used osbot for about 3 hours now and I have managed to make a fish->bank bot.. it's super simple.. 

your area is an array not really sure what you are doing there but the area should be: 

final Area MYAREA = new Area(x1,x2, x2,y2); <- this is the 2-dimensional square area, this is the grid

the areas are 2d there is no Z-axis for an area, that would be for a Position

also take a look at 

import org.osbot.rs07.api.map.constants.Banks

has some very useful default locations such as GRAND_EXCHANGE or LUMBRIDGE_UPPER for bank etc

 

then literally all you need to do is webwalk to a position.. so if(MYAREA.contains(myPosition())), then you want to 

getWalking().webWalk(Banks.LUMBRIDGE_UPPER);

for example. I don't believe you can walk to an "area" try walking to a position, which is 

import org.osbot.rs07.api.map.Position;

Edited by rawgreaze

6 hours ago, rawgreaze said:

 


final Area MYAREA = new Area(x1,x2, x2,y2); <- this is the 2-dimensional square area, this is the grid

the areas are 2d there is no Z-axis for an area, that would be for a Position

 

Area area = new Area(0,0,0,0).setPlane(0);

Plane is Z

2 hours ago, Gunman said:

 


Area area = new Area(0,0,0,0).setPlane(0);

Plane is Z

yes it sets the Z for the whole area i don't think you can make a 3d box can you? like in lumbridge you cant select the whole castle and all floors? you would have to do each floor i suppose.

also i think i know what he did, on the map he used the top 2 numbers and the 2 underneath, he should only be using the top x and y

11 minutes ago, Malcolm said:

If you wanted a 3d box you'd have to check each plane. I didn't test but probably works.


private boolean inArea() {
   final Area area = new Area(0,0,0,0);
   for (int i = 0; i < 3; i++) {
      if (area.setPlane(i).contains(myPlayer())) {
         return true;
      }
   }
   return false;
}

You could also make an Area[]{} and pass area.contains(myPlayer()) that might work

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.