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
  • Try asking for help in the chatbox
  • Efficient method for detecting if player is attacked


    kamilo
     Share

    Recommended Posts

    HI, i want to create a thread that constantly scans and waits for a person to attack me. 

    Note: im looking to see if a Player is attacking me NOT a npc. And, since my auto-retaliate will be off, i will not be attacking this player badk.

    i already know how to create a thread; im looking to get some feedback from experienced people

    My current method is to scan for all players, getPlayers().all and see if they're interacting with me. However, this might be quite taxing and might use up a lot of memory/cpu, etc..

    im not to experienced with this, so if someone can give me feedback if running such a thread scanning for players interacting with me is a bad idea to resolve this issue? 

     

    Link to comment
    Share on other sites

    Not sure how else you'd really go about doing it. Though you needn't be iterating through all loaded players, you could filter by distance, combat level etc to keep the resource usage down if you're that worried. You could also have said cycle only run if your players health bar is visible to again, stop needless memory usage.

    Link to comment
    Share on other sites

    Check the player api, there is an "IsInteractingWith" that accepts local player. should be what your looking for. there isnt really any way of avoiding scanning the players around you but like Pseudo said filtering the results down is your best bet. 

    Link to comment
    Share on other sites

    On 6/9/2020 at 11:37 AM, Pseudo said:

    Not sure how else you'd really go about doing it. Though you needn't be iterating through all loaded players, you could filter by distance, combat level etc to keep the resource usage down if you're that worried. You could also have said cycle only run if your players health bar is visible to again, stop needless memory usage.

    smart since the max attack range is 10 with bows/or mage. will def try this! thanks

    Link to comment
    Share on other sites

    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
     Share

    ×
    ×
    • 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.