Welcome!

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

Sign up now!

Resolved getAnimation() not updating

Joined
Feb 23, 2018
Messages
6
Hello, I use line "

Players.getLocal().getAnimationId()"

in my code, but it returns always -1. It doesn't seem to update that value. Am I supposed to do some newQuery to refresh values or something similar beforehand? (OSRS)

PS! Tried also method "Players.getLocal().getTarget()" but it is returning default value all the time as well but method "Players.getLocal().getPosition()" seems to work just fine. Why so ?
 
Joined
Aug 23, 2015
Messages
1,961
-1 is when youre standing still. go chop a tree or something and it will change

similarly, getTarget wont return anything unless you have a target
 
Joined
Feb 23, 2018
Messages
6
I actually am doing something. I used it as a validation argument to attack target, but even when I'm fighting target, I get default values on these methods, resulting spam clicking.

full validation argument

@Override
public boolean validate() {

if(!Npcs.getLoaded(NPC_idss).isEmpty() && Players.getLocal().getTarget() == null && Players.getLocal().getAnimationId() == -1 ){
System.out.println("Animation: " + Players.getLocal().getAnimationId() + ", players locations:" + Players.getLocal().getPosition());
return true;
}

return false;
}
 
Go check out new bots and give helpful feedback.
Joined
Jan 31, 2016
Messages
5,413
I actually am doing something. I used it as a validation argument to attack target, but even when I'm fighting target, I get default values on these methods, resulting spam clicking.

full validation argument

@Override
public boolean validate() {

if(!Npcs.getLoaded(NPC_idss).isEmpty() && Players.getLocal().getTarget() == null && Players.getLocal().getAnimationId() == -1 ){
System.out.println("Animation: " + Players.getLocal().getAnimationId() + ", players locations:" + Players.getLocal().getPosition());
return true;
}

return false;
}
Why not just do something like this
JavaScript:
Player player;
        if((player = Players.getLocal()) != null) {
            Actor target;
            if((target = player.getTarget()) != null) {
                if(target instanceof Npc) {
                    Npc targetNpc = (Npc) target;
                    //Here's your target Npc :P
                }
            }
        }
 
Joined
Aug 23, 2015
Messages
1,961
I actually am doing something. I used it as a validation argument to attack target, but even when I'm fighting target, I get default values on these methods, resulting spam clicking.

full validation argument

@Override
public boolean validate() {

if(!Npcs.getLoaded(NPC_idss).isEmpty() && Players.getLocal().getTarget() == null && Players.getLocal().getAnimationId() == -1 ){
System.out.println("Animation: " + Players.getLocal().getAnimationId() + ", players locations:" + Players.getLocal().getPosition());
return true;
}

return false;
}

A bit of constructive criticism first...
  • Don't use getLoaded, use queries. They're super optimized behind the scenes
  • You should read my guide on null checking
  • use getLogger().info("say what you want here") instead of souts
Second, you're saying that this printout always prints an animation ID of -1, even when you're fighting, or is it just sometimes?

You should join the #development channel in slack.
 
Joined
Feb 23, 2018
Messages
6
A bit of constructive criticism first...
Second, you're saying that this printout always prints an animation ID of -1, even when you're fighting, or is it just sometimes?

You should join the #development channel in slack.


It prints it all the time even while it's fighting. Weird is that getPosition() works but getAnimationId() and getTarget() do not.
 
Last edited:
Joined
Feb 23, 2018
Messages
6
Oh, found a reason. I'm using ranged in combat and during that movement bot stands still between shooting arrows which results in animation -1 so it then clicks again. Thanks for all the replies!
 
Top