SoupyOfficial Posted December 23, 2022 Share Posted December 23, 2022 Hey guys I'm fairly new to writing script and I'm still working through the API docs. Is there an easy way to check if random events appear? If not could we check the chat box for message that contain the account username? Open to any ideas Quote Link to comment Share on other sites More sharing options...
xkalibur13 Posted December 23, 2022 Share Posted December 23, 2022 (edited) I haven't been able to test this, nor have I looked into handling randomevents until now. but this would be my first stab at it: private boolean handleRandomEvent() { LocatableEntityQueryResult<NPC> results = getAPIContext().npcs().query().actions("Dismiss").results(); if(results.isEmpty()) return false; try { results.nearest().interact("Dismiss"); } catch (Exception e) { // print message for debugging purposes getLogger().debug("Caught error: " + e.getMessage()); } return true; } } lmk if you make any progress Edited December 23, 2022 by xkalibur13 Quote Link to comment Share on other sites More sharing options...
xkalibur13 Posted December 24, 2022 Share Posted December 24, 2022 I've tested this and it works private void dealWithRandomEvent() { NPC npc = npcs().query().results().nearest(); if (npc == null) return; if (!npc.hasAction("Dismiss")) return; mouse().moveRandomly(random(500,4000)); npc.interact("Dismiss"); System.out.println(npc.getName() + " dismissed"); mouse().moveOffScreen(); } 1 Quote Link to comment Share on other sites More sharing options...
illxminationrsn Posted January 19, 2023 Share Posted January 19, 2023 https://t.me/pump_upp - best crypto pumps on telegram Make 1000% and more within 1 day, join channel @pump_upp ! Quote Link to comment Share on other sites More sharing options...
Aspect Posted February 5, 2023 Share Posted February 5, 2023 https://datebest.net - visit website and win smartphone! Quote Link to comment Share on other sites More sharing options...
SoupyOfficial Posted October 2, 2023 Author Share Posted October 2, 2023 On 12/24/2022 at 4:27 AM, xkalibur13 said: I've tested this and it works private void dealWithRandomEvent() { NPC npc = npcs().query().results().nearest(); if (npc == null) return; if (!npc.hasAction("Dismiss")) return; mouse().moveRandomly(random(500,4000)); npc.interact("Dismiss"); System.out.println(npc.getName() + " dismissed"); mouse().moveOffScreen(); } After some testing I found a small bug in this code. When a random event NPC appears for another player it tries to dismiss that NPC indefinitely. Here's some untested attempts to fix the issue private void handleRandomNPC() { NPC npc = ctx.npcs().query().results().nearest(); if (npc == null) return; if (!npc.hasAction("Dismiss") || !npc.getMessage().contains("SoupyOficial") || !npc.isInteractingWithMe()) return; ctx.mouse().moveRandomly(Random.nextInt(500,4000)); npc.interact("Dismiss"); System.out.println(npc.getName() + " dismissed"); randomsHandled++; ctx.mouse().moveOffScreen(); } Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.