Advertisement
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Solved Distance from player to player

Comments in 'Plugin Development' started by XEmAX32, Sep 29, 2015.

  1. XEmAX32
    Offline

    XEmAX32 Active Member

    Joined:
    Feb 1, 2015
    Posts:
    80
    Minecraft User:
    XEmAX32
    Hi guys if you know can you tell me how to check the distance from a player to another player?

    <?php

    namespace CompassDistance;

    use pocketmine\utils\TextFormat;
    use pocketmine\plugin\PluginBase;
    use pocketmine\event\player\PlayerInteractEvent;
    use pocketmine\event\Listener;

    class Main extends PluginBase implements Listener{

    public function onEnable(){
    $this->getServer()->getPluginManager()->registerEvents($this, $this);
    }


    public function OnInteract(PlayerInteractEvent $e){
    $player = $e->getPlayer();
    $playername = $e->getPlayer()->getName();
    $block = //??? I don't know xD
    if($player->getInventory()->getItemOnHand() == Item::345){
    $player->sendMessage(TextFormat::AQUA . "[CompassDistance] You are $blocks from $playername ");
    }
    }
    }
    ?>
  2. Svile
    Offline

    Svile Active Member

    Joined:
    Mar 30, 2015
    Posts:
    239
    Minecraft User:
    svile
    PHP:
    $player->getPosition()->distance($otherplayerposition);
  3. XEmAX32
    Offline

    XEmAX32 Active Member

    Joined:
    Feb 1, 2015
    Posts:
    80
    Minecraft User:
    XEmAX32
    thanks
    Grandissimo Svileeee
    Svile likes this.
  4. Svile
    Offline

    Svile Active Member

    Joined:
    Mar 30, 2015
    Posts:
    239
    Minecraft User:
    svile
    ;)
  5. XEmAX32
    Offline

    XEmAX32 Active Member

    Joined:
    Feb 1, 2015
    Posts:
    80
    Minecraft User:
    XEmAX32
    thnx luca :D

Share This Page

Advertisement