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.

String comparison problem

Featured Replies

I am writing a function that checks if a specific player is on my friendslist, and not sure what I am missing in here...

public boolean isFriend(String name) {
        RS2Widget widget = script.widgets.get(429, 9);
        if (widget == null)
            return false;

        for (RS2Widget friend : widget.getChildWidgets()) {
            if (friend.getMessage().equals(name)) {
                return true;
            }
        }

        return false;
    }

The following code works pretty well if the name is not separated.

Example of a working check: abc123 -> If is on the list, returns true, otherwise, returns false

Example of a non-working check: the king -> this will keep returning false whether or not the player is on my friend list

 

Thanks in advance!

Edited by fredrico123

23 minutes ago, fredrico123 said:

I am writing a function that checks if a specific player is on my friendslist, and not sure what I am missing in here...


public boolean isFriend(String name) {
        RS2Widget widget = script.widgets.get(429, 9);
        if (widget == null)
            return false;

        for (RS2Widget friend : widget.getChildWidgets()) {
            if (friend.getMessage().equals(name)) {
                return true;
            }
        }

        return false;
    }

The following code works pretty well if the name is not separated.

Example of a working check: abc123 -> If is on the list, returns true, otherwise, returns false

Example of a non-working check: the king -> this will keep returning false whether or not the player is on my friend list

 

Thanks in advance!


The player names in the widgets probably have non-breaking spaces instead of regular spaces:
 

if (friend.getMessage().replace('\u00A0', ' ').equals(name))


Or at the top of your function:

name = name.replace(' ', '\u00A0');

 

Edited by Explv

  • Author

Maybe just one more question, please. How do I know which one to use and when?

Edited by fredrico123

18 minutes ago, fredrico123 said:

Maybe just one more question, please. How do I know which one to use and when?

Can check while debugging in OSBots widget debugger

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.