kamilo 7 Share Posted June 9, 2020 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 More sharing options...
Pseudo 179 Share Posted June 9, 2020 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 More sharing options...
TheCloakdOne 389 Share Posted June 9, 2020 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 More sharing options...
kamilo 7 Author Share Posted June 11, 2020 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 More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.