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.

Replace(Char, char) error

Featured Replies

I got the error "The method replace(char char) is undefined for the type Player". How should I go about removing the space from the name? :( 

Inb4 super easy fix and I feel like a complete noob. ^^

	public void sendRequest() throws InterruptedException	{

		Player Name = getPlayers().closest("Example Name");
		Name = Name.replace(' ', '_');
		
    if (Name != null && Name.isVisible()) {
    	Name.interact("Trade with");
    	sleep(random(2000, 3000));
    	new ConditionalSleep(5000, 500) {
                @Override
                public boolean condition() throws InterruptedException {
                    return getTrade().isCurrentlyTrading();
                }
            }.sleep();
        }
    }

 

  • Author
6 minutes ago, Camaro said:

need double quotes

Name.replace(" ", "_");

Still getting the same error. :( 

1 minute ago, Lol_marcus said:

Still getting the same error. :( 

Just realized what youre trying to do

        Player Name = getPlayers().closest("Example Name");
        Name = Name.replace(' ', '_');

Name is a Player instance. Youre trying to call a String function

        Player player = getPlayers().closest("Example Name");
        String name = player.getName().replace(' ', '_');

also forget what I said above, single quotes work fine

  • Author
1 hour ago, Camaro said:

Just realized what youre trying to do

        Player Name = getPlayers().closest("Example Name");
        Name = Name.replace(' ', '_');

Name is a Player instance. Youre trying to call a String function

        Player player = getPlayers().closest("Example Name");
        String name = player.getName().replace(' ', '_');

also forget what I said above, single quotes work fine

I've tried that now, and I'm getting a different error. 

"The method interact(String) is undefined for the type String"

It has something to do with name.interact, because if I change that to "player.interact", it doesn't give an error, but it doesn't trade my player. :???:

	public void sendRequest() throws InterruptedException	{

		Player player = getPlayers().closest("Example Name");
		String name = player.getName().replace(' ', '_');
		
    if (name != null && player.isVisible()) {
    	name.interact("Trade with");
    	sleep(random(2000, 3000));
    	new ConditionalSleep(5000, 500) {
                @Override
                public boolean condition() throws InterruptedException {
                    return getTrade().isCurrentlyTrading();
                }
            }.sleep();
        }
    }

 

6 minutes ago, Lol_marcus said:

I've tried that now, and I'm getting a different error. 

"The method interact(String) is undefined for the type String"

It has something to do with name.interact, because if I change that to "player.interact", it doesn't give an error, but it doesn't trade my player. :???:


	public void sendRequest() throws InterruptedException	{

		Player player = getPlayers().closest("Example Name");
		String name = player.getName().replace(' ', '_');
		
    if (name != null && player.isVisible()) {
    	name.interact("Trade with");
    	sleep(random(2000, 3000));
    	new ConditionalSleep(5000, 500) {
                @Override
                public boolean condition() throws InterruptedException {
                    return getTrade().isCurrentlyTrading();
                }
            }.sleep();
        }
    }

 

Why do you need to take the spaces out in the first place?

  • Author
13 minutes ago, Camaro said:

Why do you need to take the spaces out in the first place?

I read on another posts that if you have a space in your name you have to remove it, otherwise the bot won't recognize your name/won't trade you. :/

11 minutes ago, Lol_marcus said:

I read on another posts that if you have a space in your name you have to remove it, otherwise the bot won't recognize your name/won't trade you. :/

Not sure exactly how that works, but this might

Player p = getPlayers().singleFilter(p -> p != null && p.getName().replace(" ", "").equals("namewithoutspaces"))

Edited by Camaro

45 minutes ago, Lol_marcus said:

I've tried that now, and I'm getting a different error. 

"The method interact(String) is undefined for the type String"

It has something to do with name.interact, because if I change that to "player.interact", it doesn't give an error, but it doesn't trade my player. :???:


	public void sendRequest() throws InterruptedException	{

		Player player = getPlayers().closest("Example Name");
		String name = player.getName().replace(' ', '_');
		
    if (name != null && player.isVisible()) {
    	name.interact("Trade with");
    	sleep(random(2000, 3000));
    	new ConditionalSleep(5000, 500) {
                @Override
                public boolean condition() throws InterruptedException {
                    return getTrade().isCurrentlyTrading();
                }
            }.sleep();
        }
    }

 

"The method interact(String) is undefined for the type String"
Read your logic. name is now type of String 
It is not type of Player anymore. You now need to do player.interact("trade with") or whatever

also rs using a different space character

 

.replace(' ', '\u00A0')

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.