How to create FloatingText for only one player?

Discussion in 'Development' started by LewBr, Apr 25, 2018.

  1. LewBr

    LewBr Zombie

    Messages:
    382
    GitHub:
    lewbr
    Hello, how could i create a particle for only one player that the others should not see this?
    this is how i create a normal particle:
    PHP:
     Player->getLevel()->addParticle(new \pocketmine\level\particle\FloatingTextParticle(new Vector3(256.564.9255.5), "Particle :)")); 
    How can i create a particle for one player just? Should i use packets and manage data of them right? can someone give me an example of how can work that?
     
  2. RyanShaw

    RyanShaw Witch

    Messages:
    70
    I'm pretty sure you add just one particle per player by adding [$player] as the second argument for addParticle. So it goes something like this
    PHP:
      Player->getLevel()->addParticle(new \pocketmine\level\particle\FloatingTextParticle(new Vector3(256.564.9255.5), "Particle :)"), [$player]); 
     
  3. LewBr

    LewBr Zombie

    Messages:
    382
    GitHub:
    lewbr
    Hmm.. thank you, i will test and saw if works or not..
     
    RyanShaw likes this.
  4. MalakasPlayzMCPE

    MalakasPlayzMCPE Zombie Pigman

    Messages:
    514
    Player->getLevel()!?!?
    Replace with $player or whatever you defined as player otherwise you will get errors
     
  5. Daniktheboss

    Daniktheboss Baby Zombie

    Messages:
    148
    GitHub:
    daniktheboss
    What?
     
  6. LewBr

    LewBr Zombie

    Messages:
    382
    GitHub:
    lewbr
    what? i know what a variable is lololloll
     
    OnTheVerge and RyanShaw like this.
  7. Kyd

    Kyd Zombie Pigman

    Messages:
    662
    PHP:
    /** @var FloatingTextParticle $particle */
    /** @var Player $player */

    foreach($particle->encode() as $packet){
          
    $player->dataPacket($packet);
    }
     
    RyanShaw likes this.
  8. xXNiceAssassinlo YT

    xXNiceAssassinlo YT Zombie Pigman

    Messages:
    619
    GitHub:
    xXNiceYT
    PHP:
    $text = new FloatingTextParticle(new Position(123123123$this->getServer()->getDefaultLevel()), " ""Yo");
    $this->getServer()->getDefaultLevel()->addParticle($text, [$player]);
     
  9. Levi

    Levi Zombie Pigman

    Messages:
    614
    GitHub:
    captainleviftw
    why didn't you define the player then? technically Player->getLevel() is not very right and looks ugly
     
  10. LewBr

    LewBr Zombie

    Messages:
    382
    GitHub:
    lewbr
    Lmao, variable is instance of pocketmine\Player that's why i write that, but my variable is $player, go learn pls.. :facepalm:
     
  11. Levi

    Levi Zombie Pigman

    Messages:
    614
    GitHub:
    captainleviftw
    You are the one asking the question here
     
    Harvey likes this.
  12. LewBr

    LewBr Zombie

    Messages:
    382
    GitHub:
    lewbr
    I was not asking nothing anymore, before you come back to this thread and say that. And for learning i was telling you for php, not pocketmine. o_O:facepalm:
     
  13. Levi

    Levi Zombie Pigman

    Messages:
    614
    GitHub:
    captainleviftw
    How would anyone know that? This question was the 5th one in the forum and was not marked "Solved". Moron.
     
  14. LewBr

    LewBr Zombie

    Messages:
    382
    GitHub:
    lewbr
    Okay, man, I did not know that this was mandatory in the forum, if the objective was to help the person who asked the question, do not need to mark as resolved if the answers have already helped, just mark as resolved if you want, I will not be punished for it, Contrary to you who lowered the level to the point of cursing me, grows before answering someone on the internet, please.
     
  15. Primus

    Primus Zombie Verified

    Messages:
    290
    LewBr likes this.

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.