1. The forums will be archived and moved to a read only mode in about 2 weeks (mid march).

Selecting An Area

Discussion in 'Facepalm' started by 3XPPro, Jul 13, 2017.

  1. 3XPPro

    3XPPro Shog Chips

    Messages:
    0
    Ok so i'm having this problem where i want to stop a command from executing within a 200 by 200 area with the center as 0,70,0 and i used this to do so,
    PHP:
    if (($x 100 or $x > -100) and ($z 100 or $z > -100)){
            return 
    true;
    }
    However it goes past the area i want to stop because when a player is in a positive x coordinate
    $x > -100 includes all the positives as well . how can i stop it at 0 or -1? instead of it going into the positives?
    or is there a way to do this better?
     
  2. Thunder33345

    Thunder33345 Moderator Staff Member

    Messages:
    2,137
    GitHub:
    Thunder33345
    i would just use new Vector3->distance
    or you simply meant $x < -100
    PHP:
    <?php
    $x 
    = -2;
    if (
    $x > -1) echo "true1";
    if (
    $x < -1) echo "true2";
    Code:
    true2
    
    see https://eval.in/832200
     
    3XPPro likes this.
  3. Muqsit

    Muqsit Chicken

    Messages:
    1,548
    GitHub:
    muqsit
    Last time I checked, commands didn't require a Vector.

    Lett me simplify what you wrote.
    PHP:
    if($x > -100 and $z > -100) {
        return 
    true;
    }
    Possibly, you meant a 200x200 region from x(-100 to 100) and z(-100 to 100), which should've been:
    PHP:
    if($x > -100 and $x 100 and $z > -100 and $z 100){
        
    //Player is in (X={-100, -99, ...100}, Z={-100, -99,... 100})
    }
     
    3XPPro likes this.
  4. SOFe

    SOFe Administrator Staff Member PMMP Team Poggit Admin

    Messages:
    1,968
    GitHub:
    sof3
    3XPPro and Muqsit like this.
  5. 3XPPro

    3XPPro Shog Chips

    Messages:
    0
    Thanks Everyone!!! i got it working perfectly. Thanks @Muqsit for the code!
     
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.