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
  • Get Player Under Mouse


    Paradoxum

    Recommended Posts

    Hi,

    I've been working on a sort of semi-automatic script that assists a human player doing basic mundane tasks, and am trying to find a way to get a reference to a player (or entity) that exists under the mouses current position. Can anyone think of an efficient way to accomplish this? Currently I'm simply following the player, then getting the interacting character using this:

     

    final Character interactingWith = main.getLocalPlayer().getInteractingCharacter();
                                if (interactingWith != null)
                                    main.hsLookup(interactingWith.getName());

    This is however, getting very troublesome having to constantly follow players when I want to get a reference to them. Is there any way to get a list of player's/characters under the mouses hovered position?

     

    EDIT:

    Nvm, just found my answer in the API !

    getMouse().getEntitiesOnCursor()

    is exactly what i needed.

     

    Thanks

    Link to comment
    Share on other sites

    You can load and store every local player, then probably determine the player(s) at the mouse location by determining the tile/position at which the mouse is existent and comparing this to the location of the players.

    Link to comment
    Share on other sites

    Just now, Pseudo said:

    You can load and store every local player, then probably determine the player(s) at the mouse location by determining the tile/position at which the mouse is existent and comparing this to the location of the players.

    Yeeaaahh... I was thinking of this... I was just hoping there would be a way without searching through every single player, as in the area I'm in this would mean hundreds.

    Link to comment
    Share on other sites

    39 minutes ago, Paradoxum said:

    Yeeaaahh... I was thinking of this... I was just hoping there would be a way without searching through every single player, as in the area I'm in this would mean hundreds.

    Well you could filter the search down to a smaller radius, so you'd only then iterate over the players in say, a 10 tile radius from our local player.

    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.