Jump to content
Frequently Asked Questions
  • Are you not able to open the client? Try following our getting started guide
  • Still not working? Try downloading and running JarFix
  • Help! My bot doesn't do anything! Enable fresh start in client settings and restart the client
  • How to purchase with PayPal/OSRS/Crypto gold? You can purchase vouchers from other users
  • Getting players in an area in a loop


    boogzey

    Recommended Posts

    I want to just have my character stand in an area and send the player names to my server. I don't have an issue making the HTTP requests, but how can I use Player to return the players in my area? I checked out the docs and it seems like getPlayers().all(); is the way to go. 

     

    Can anyone point me in the right direction for logging players around me to the console?

     

    Thanks.

    Link to comment
    Share on other sites

    4 minutes ago, Milasoft said:
    
    List<Player> playerList = getPlayers().all();
    playerList.forEach(p -> {
    	log(p.getName());
    });

    You could do something like that.

     

    Thanks, this looks good. Unfortunately, I can't get it to work. Here's the issue:

     

    Error:(24, 9) java: cannot find symbol
      symbol:   class List
      location: class main.Main
    Error:(24, 14) java: cannot find symbol
      symbol:   class Player
      location: class main.Main

     

    I think the first issue has something to do with Java not recognizing the list type, but I have the following at the top of my file:

    import java.util.List;

     

    Any idea why that's happening?

     

    As for the second issue, I'm not sure why that's happening either. I am importing Players like so:

    import org.dreambot.api.methods.interactive.Players;

     

    Apologies if these are dumb questions. I come from a Python background.

     

    Thanks for the help!

    Link to comment
    Share on other sites

    6 minutes ago, Milasoft said:
    
    import org.dreambot.api.wrappers.interactive.Player;

    Are you not using an IDE?

    I'm using IntelliJ. Why?

     

    Edit: that import works perfectly. Can you tell me where in the docs that is? Also, what was the import I was using previously for? 

    Link to comment
    Share on other sites

    5 minutes ago, Milasoft said:

    Oh, because it usually shows you in red where it's messed up and you can pick the import from there. :P 

    Haha damn. Like I said, pretty new to Java/this IDE. Thanks for the help man! Really appreciate it.

    Link to comment
    Share on other sites

    Archived

    This topic is now archived and is closed to further replies.

    ×
    ×
    • Create New...

    Important Information

    We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.