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 properly trade with players?

Featured Replies

I had previously tried to use the code below but it kept giving me null pointer exception.

getPlayers().closest("Name").interact("Trade with"); 

I did find this to work, however the index does change with a logout, and I'm not sure of how to update the index upon player login.

getPlayers().getLocalPlayer(325).interact("Trade with");

Edited by boxo

43 minutes ago, d0zza said:

Are you checking if the player is not null?

^ this.

if the player is not around, closest() will return null, and because you're calling a method on that null, you'll get an NPE.

  • Author

I did not perform a null check to see if the player i want to trade is around, however the player I wanted to trade with was in the same exact bank I was in.

I've always just written player.interact("Trade with") and never had an issue

 

11 minutes ago, Slut said:

I've always just written player.interact("Trade with") and never had an issue

He's doing the same thing, just not storing the player he wants to interact with.

15 minutes ago, boxo said:

I did not perform a null check to see if the player i want to trade is around, however the player I wanted to trade with was in the same exact bank I was in.

Perform the null check anyway because I'm 99.9% sure that's the issue. If it still happens let me know.

  • Author

So I tested the following code with a different  name than the one I was using originally, which I obviously made sure was spelt correctly about 10 different times, and it worked.... for future reference my account name was something similar to "big slap head". With one space after the first and second word, I'm not sure why it wasn't properly working with an account name that had two spaces like mine but it was working on other accounts. Thanks for the help.

if (getPlayers().closest("name")!=null)
{
    getPlayers().closest("name").interact("Trade with");
}

 

Edited by boxo

48 minutes ago, boxo said:

So I tested the following code with a different  name than the one I was using originally, which I obviously made sure was spelt correctly about 10 different times, and it worked.... for future reference my account name was something similar to "big slap head". With one space after the first and second word, I'm not sure why it wasn't properly working with an account name that had two spaces like mine but it was working on other accounts. Thanks for the help.


if (getPlayers().closest("name")!=null)
{
    getPlayers().closest("name").interact("Trade with");
}

 

For accounts with spaces in their names you'll need to replace the space character with another character, see the second post in this thread

 

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.