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

If players is in radius

Discussion in 'Facepalm' started by #A6543, Feb 9, 2017.

  1. #A6543

    #A6543 Zombie

    Messages:
    267
    I tried to check if there is a special block in a radius of 7 blocks from a player. I placed a sign under the block. But it only works sometimes. What is wrong?
    PHP:
    foreach ($player->getLevel()->getTiles() as $b) {
    if(
    $b instanceof Sign) {
    $distance sqrt(($player->$b->x)*($player->$b->x) + ($player->$b->y)*($player->$b->y) + ($player->-
    $b->z)*($player->$b->z));
    if (
    $distance 7) {

    }
     
  2. wolfdale

    wolfdale Zombie Pigman

    Messages:
    535
    GitHub:
    diamond-gold
    You can try
    PHP:
    foreach ($player->getLevel()->getTiles() as $b) {
        if(
    $b instanceof Sign) {
            if(
    $b->distanceSquared($player) < 49){
            
    //do smth
            
    }
        }
    }
     
  3. Bluplayz

    Bluplayz Spider Jockey

    Messages:
    43
    GitHub:
    bluplayz
  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.