May 18, 20205 yr 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(); } }
May 18, 20205 yr Author 6 minutes ago, Camaro said: need double quotes Name.replace(" ", "_"); Still getting the same error.
May 18, 20205 yr 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
May 18, 20205 yr 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(); } }
May 18, 20205 yr 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?
May 18, 20205 yr 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.
May 18, 20205 yr 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 May 18, 20205 yr by Camaro
May 18, 20205 yr 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
May 18, 20205 yr Author I finally f*cking got it to work! xD Thanks guys Edited May 18, 20205 yr by Lol_marcus
Create an account or sign in to comment