Jump to content

List allPlayers = getPlayers().getAll(); - How to get display names?


Recommended Posts

Posted (edited)

Hi brothers, how do you get the display name of other characters?

 

Im get only

org.osbot.rs07.api.model.Player@1f2b425

And it dont match with my admin string

			if (getInventory().contains(7936) && getInventory().getAmount(7936) > 4) {
				// trade for ess	
				java.util.List<Player> allPlayers = getPlayers().getAll();
				if (!hosts.contains(admin)) {
					hosts.add(admin);
				}
				if (allPlayers != null) {
					for (int i = 0; i < allPlayers.size(); i++) {
						log(allPlayers.get(i));
						log(hosts);
						if (hosts.contains(allPlayers.get(i))) {
							playerMatch = allPlayers.get(i);
							//playerMatch.interact("Follow");
							break;
						}
						
					}
					new ConditionalSleep(2000) {
						@Override
						public boolean condition() throws InterruptedException {
							return trade.isFirstInterfaceOpen();
						}
					}.sleep();
					if (trade.isCurrentlyTrading()) {
						if (trade.isFirstInterfaceOpen()) {
							trade.offerAll(7936);
						}
						if (trade.getTheirOffers().onlyContains(7937, 995) && trade.didOtherAcceptTrade()) {
							trade.acceptTrade();
						}
						if (trade.isSecondInterfaceOpen() && trade.getTheirOffers().onlyContains(7937, 995)
								&& trade.didOtherAcceptTrade()) {
							trade.acceptTrade();
						}
					}
				}
			}
Edited by semanji
Posted (edited)

 

Hi brothers, how do you get the display name of other characters?

 

Im get only

org.osbot.rs07.api.model.Player@1f2b425

And it dont match with my admin string

			
if (hosts.contains(allPlayers.get(i))) 
										

 

use getName(), but you will also need to account for non breaking spaces in their name so use:

if (hosts.contains(allPlayers.get(i).getName().replace('\u00A0', ' ')))
Edited by Explv
  • Like 1

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...