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

checkForPlayers

Discussion in 'Development' started by Remarkabless, Dec 11, 2017.

  1. Remarkabless

    Remarkabless Slime

    Messages:
    83
    GitHub:
    Remakem
    how can i check if there are players in my radius, like a
    PHP:
    public function checkRadius($player)
    So that later I can call it in my other function?

    How can i give the players in the radius something once I check. Thanks hopefully I explained it more descriptive than before!
     
  2. xXNiceAssassinlo YT

    xXNiceAssassinlo YT Zombie Pigman

    Messages:
    499
    GitHub:
    xXNiceYT
    Please send all code that.
     
  3. Thunder33345

    Thunder33345 Moderator Staff Member

    Messages:
    2,137
    GitHub:
    Thunder33345
    You should do
    radius($player,$range)
    so
    $players
    foreach $player->getviewers as $other
    if ($dist = $player->distance($other)) >= $range
    $players[$dist][] = $player
    OR
    foreach $player->getlevel->getplayers() ...
    depending on the range as getviewers probably wont be so long ranged but is optimal for shortranges
     
    Remarkabless likes this.
  4. Kyd

    Kyd Zombie Pigman

    Messages:
    678
    GitHub:
    boi1216
    PHP:
    public function contains($x$y$z$x1$y1$z1Vector3 $pos)
        {
            
    $axis = new AxisAlignedBB($x$y$z$x1$y1$z1);
            if (
    $axis->isVectorInside($pos)) {
                return 
    true;
            }
            return 
    false;
        }
     
  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.