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

Stop players from going to a certain area..

Discussion in 'Development' started by Levi, Dec 7, 2017.

  1. Levi

    Levi Skeleton

    Messages:
    955
    GitHub:
    captainleviftw
    I want to make a forcefield kind of that blocks anyone from getting in if they do not have permission>>
    PHP:
    onPlayerMoveEvent

    $x 
    $player->getX();
    $y $player->getY();
    $z $player->getZ();
    if(
    $player->hasPermission("Forfild"){
    if((
    $x 120) && ($y 50) && ($z 150)){
    // push player like 2 block far
    }
    }
     
  2. KittyDev

    KittyDev Slime

    Messages:
    96
    GitHub:
    FreakingDev
    Suggestion: Try to send message first if they reach that
     
  3. Thunder33345

    Thunder33345 Moderator Staff Member

    Messages:
    2,137
    GitHub:
    Thunder33345
    you can do set canceled
    but i prefer something like knocking back from directional vector i think it has been done before i read it somewhere but cant remember it off my heads
    you can also just knock player + x then +z till they are out of it
    irrelevant to stopping players reaching that point
     
  4. Muqsit

    Muqsit Chicken

    Messages:
    1,548
    GitHub:
    muqsit
  5. Ant

    Ant Spider

    Messages:
    9
    GitHub:
    Dead
    Something like this should work.
    PHP:
    $force 3.5;
    $d $e->getTo()->subtract($e->getFrom())->normalize()->multiply($force);
    $player->knockback($player0$d->x$d->z);
     
    Last edited: Dec 7, 2017
    Levi likes this.
  6. Muqsit

    Muqsit Chicken

    Messages:
    1,548
    GitHub:
    muqsit
    Pretty sure the XZ plane is needed for knockback
     
    xXNiceAssassinlo YT and Levi like this.
  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.