player location

Discussion in 'Development' started by Hen1, Oct 28, 2017.

  1. Hen1

    Hen1 Silverfish

    Messages:
    21
    <?php

    namespace SkyHard;

    use pocketmine\Player;
    use pocketmine\Server;
    use pocketmine\event\player\PlayerInteractEvent;
    use pocketmine\event\Listener;
    use pocketmine\plugin\PluginBase;
    use pocketmine\item\Item;
    use pocketmine\block\Block;

    class Main extends PluginBase implements Listener{

    public $prefix = "§a»§r§7";

    public function onEnable(){
    $this->getServer()->getLogger()->info($this->prefix."ativo");
    $this->getServer()->getPluginManager()->registerEvents($this, $this);

    }

    public function onInteract(PlayerInteractEvent $ev){
    $player = $ev->getPlayer();
    $item = $ev->getItem();
    $block = $ev->getBlock();
    if($item->getId() == 345){
    $closest = "nullbody";

    $algo = $event->getName();
    foreach($this->getServer()->getOnlinePlayers() as $p){
    if($p !== $player){
    $x = $p->x - $player->x;
    $z = $p->z - $player->z;
    $square = abs($x) + abs($z);
    if($lastSquare === -1 or $lastSquare > $square){
    $closest = $p->getName();
    $algo = $event->getName();
    $player->sendPopup($this->prefix." §eApontando Para §a".$algo."");

    }
    }
    }
    }
    }
    }
     
  2. HimbeersaftLP

    HimbeersaftLP Chicken

    Messages:
    1,527
    GitHub:
    HimbeersaftLP
    Please use PHP-Codeblocks:
    [php]Your code comes here[/php]
     
    Muqsit, Edwardthedog2 and Sandertv like this.
  3. LewBr

    LewBr Zombie

    Messages:
    385
    GitHub:
    lewbr
    Por favor, diga os erros para poder entender oque você precisa.
    Please, tell us the issue or what you want so i can read what you want.
     
    Hen1 and HimbeersaftLP like this.
  4. Sandertv

    Sandertv Skeleton Poggit Reviewer

    Messages:
    802
    GitHub:
    Sandertv
    Cake
    Code:
                 (        (
                 ( )      ( )          (
          (       Y        Y          ( )
         ( )     |"|      |"|          Y
          Y      | |      | |         |"|
         |"|     | |.-----| |---.___  | |
         | |  .--| |,~~~~~| |~~~,,,,'-| |
         | |-,,~~'-'___   '-'       ~~| |._
        .| |~       // ___            '-',,'.
       /,'-'     <_// // _  __             ~,\
      / ;     ,-,     \\_> <<_' ____________;_)
      | ;    {(_)} _,      ._>>`'-._          |
      | ;     '-'\_\/>              '-._      |
      |\ ~,,,      _\__            ,,,,,'-.   |
      | '-._ ~~,,,            ,,,~~ __.-'~ |  |
      |     '-.__ ~~~~~~~~~~~~ __.-'       |__|
      |\         `'----------'`           _|
      | '=._                         __.=' |
      :     '=.__               __.='      |
       \         `'==========='`          .'
    snd '-._                         __.-'
            '-.__               __.-'
                 `'-----------'`
    [/php]
    Perhaps next time make clear what your problem is.
     
  5. Hen1

    Hen1 Silverfish

    Messages:
    21
    • And start using English! You have been reminded several times!
    ao interagir com o item localizar o jogador mais proximo
     
  6. Hen1

    Hen1 Silverfish

    Messages:
    21
    na verdade só aparecer o nick dele
     
  7. LewBr

    LewBr Zombie

    Messages:
    385
    GitHub:
    lewbr
    Existe algum tipo de erro no Console?
    Após você clicar no item não aparece popup? qual o erro realmente?
    Por favor diga os erros reais e coloque
    PHP:
    seu código
     
  8. robske_110 (Tim)

    robske_110 (Tim) Wither Skeleton Poggit Reviewer Verified

    Messages:
    1,374
    GitHub:
    robske110
    please speak english here :)
     
  9. LewBr

    LewBr Zombie

    Messages:
    385
    GitHub:
    lewbr
    Altere
    $algo = $event->getName(); para $algo = $p->getName();
     
  10. Hen1

    Hen1 Silverfish

    Messages:
    21
    Este codigo é do meu amigo burro kkkj eu não entendi oq ele estava tentando fazer
    este codigo é de um amigo ele é mto burro ._. e eu n soube ajuda´lo então pedi ajuda aqui
     
  11. LewBr

    LewBr Zombie

    Messages:
    385
    GitHub:
    lewbr
    Por favor, na próxima vez crie um post melhor e mais dedicado, se o problema foi resolvido altere a tag da postagem para [Solved] na opçãozinha ali do lado e obrigado.
     
  12. robske_110 (Tim)

    robske_110 (Tim) Wither Skeleton Poggit Reviewer Verified

    Messages:
    1,374
    GitHub:
    robske110
    Again, please speak in english.
     
  13. Hen1

    Hen1 Silverfish

    Messages:
    21
    [QUOTE = "robske_110 (Tim), post: 40727, membro: 14"] por favor fale inglês aqui :)[/ QUOTE]
    animated particles onPlayerMove example or ItemHeld
     
  14. LewBr

    LewBr Zombie

    Messages:
    385
    GitHub:
    lewbr
    He has an noob issue on code: like $algo = $event->getName(); but is $algo = $p->getName();
    But has been fixed, i think.
    Have you fixed that? $event->getName() to $p->getName()
     
  15. Hen1

    Hen1 Silverfish

    Messages:
    21
    [QUOTE = "LewBr, post: 40750, member: 1024"] Ele tem um problema noob no código: como $ algo = $ event-> getName (); mas é $ algo = $ p-> getName ();
    Mas foi corrigido, penso.

    Você corrigiu isso? $ event-> getName () para $ p-> getName () [/ QUOTE]
    si! falei para ele mas não adiantou :V
     
  16. Kyd

    Kyd Zombie Pigman

    Messages:
    678
    !!!!!!!!!!!!!!!!!!!!!!!!!!
     
  17. DanielYTK

    DanielYTK Zombie

    Messages:
    227
    portugues: Cara, se você não falar inglês aqui, eles vão te banir do FORUM, é melhor falar inglês, sério.
    inglish: Man, if you don't speak inglish here, they will ban you from FORUM, is best talk inglish, please.
     
    jasonwynn10 likes this.
  18. WinterBuild7074

    WinterBuild7074 Zombie Pigman

    Messages:
    699
    GitHub:
    winterbuild7074
    @Hen1 If you really want to speak Portuguese with @LewBr, do it in a DM/Private Conversation or someplace else.
     
    jasonwynn10 likes this.
  19. Hen1

    Hen1 Silverfish

    Messages:
    21
    Ok!!!! Sorry sksksk
     
  20. Hen1

    Hen1 Silverfish

    Messages:
    21
    Sorry! ;-;
     

Share This Page

  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.