Jump to content

Checking to see if a user is in the right position


imJordanB

Recommended Posts

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 :)

Link to comment
Share on other sites

 

 
 
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
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

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