Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

Sign up now!

Question Better method to prevent clicking when animation = -1 ?

Joined
Apr 22, 2017
Messages
34
So basically right now like others have had in the past is solving how to handle when the players animation is -1 caught in-between animations.

I've mostly seen a lazy hacky fix which people resort to relying on some sort of delay to have it occur less but has some issues like;
- It's not humanlike
- It makes the script less efficient
- It can still break the logic sequence but its just made rarer

Right now my basic checks are something similar which can cause needless/spammy clicking;

Code:
if(Players.getLocal().isMoving() == false){
    if(Players.getLocal().getAnimationId() == -1){
        if(someGameObject.isValid() && someGameObject.isVisible()){
            someGameObject.interact("Do something");
        }
    }
}

I've seen people throwing in a Execution.Delay but for me doesn't seem to be the correct way to handle it.

-----------------------------------------------

I've so far have two solutions which is why I'm wondering if anyone else has a better method to handle it.

A) Use the chat listener and grab the messages with a timer. When the filtered message isn't received within a time span reset a variable (something like "areWeDoingStuff = false") and have that also be included as a check. (Doesn't work for all scripts)

B) Create a player animation handler that grabs the player animation and has a timer with a saved animation queue for the last 5 attempts. When the last 5 animations in queue are all -1 just reset a variable like the first solution and include it in the check.


(Small note; Haven't been programming in quite a long time as well so I'm relearning most APIs once again so any complex solutions would be helpful if they're explained a bit)
 
Last edited:
Joined
May 24, 2016
Messages
1,113
Look into the Execution class. There are ways to make your delay reset using a condition, which is the proper way to do it.
 
Joined
Apr 22, 2017
Messages
34
Look into the Execution class. There are ways to make your delay reset using a condition, which is the proper way to do it.

Yeah that was my second solution to handling it but looks like the delayUntil would use less resources.
 
Top