Jump to content

Checking to see if a user is in the right position


Recommended Posts

Posted

So I am working on a cannon bot (my first ever script) and want to check whether the user is in the right position before placing down the cannon.

How do I check a users position to ensure they are in the right position using an IF statement? (I have the co-ordinates of the position written down, I just need to know how to do the comparison of my co-ordinates to the users position)

 

Thanks :)

Posted

 

 
 
if (myPlayer().getPosition().equals(new Position(x, y, z))) {
    //there
}
else {
    //not there
}

 

Thanks a lot, I appreciate it

 

 
 
if (myPlayer().getPosition().equals(new Position(x, y, z))) {
    //there
}
else {
    //not there
}

 

One more question: How would I go about it without an else statement? What if I want to say "If position does not equal this position"

  • Like 1

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...