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

Show a different popup

Comments in 'Plugin Development' started by AndrewBit, Jul 28, 2016.

  1. AndrewBit
    Offline

    AndrewBit Notable Member

    Joined:
    Jun 18, 2015
    Posts:
    435
    Minecraft User:
    AndrewBit4
    How I can show a different popup to each player in the server?
    Let's say I've got two arrays with different players...

    How to show a different popup to the people inside the first array?
  2. CrazedMiner
    Offline

    CrazedMiner Notable Member Plugin Developer

    Joined:
    Jan 31, 2015
    Posts:
    348
    Plugins:
    2
    Minecraft User:
    CrazedMinerYT
    PHP:
    /** @var pocketmine\Player[] $array1 */
    $array1 = [];
    /** @var pocketmine\Player[] $array2 */
    $array2 = [];
    foreach(
    $array1 as $arr1) {
        
    $arr1->sendPopup("Your popup");
    }
    foreach(
    $array2 as $arr2) {
        
    $arr2->sendPopup("Your popup #2");
    }
    PocketKiller likes this.
  3. AndrewBit
    Offline

    AndrewBit Notable Member

    Joined:
    Jun 18, 2015
    Posts:
    435
    Minecraft User:
    AndrewBit4
    Lmao, I recently realized I explained really bad my question.
    I mean FloatingTextPopups :oops:
  4. Extreme_Heat
    Offline

    Extreme_Heat Active Member

    Joined:
    Apr 19, 2016
    Posts:
    76
    Minecraft User:
    Extreme_Heat
    Are you talking about FloatingTextParticle? When you call Level::addParticle(), add a second parameter with an array of all the players that are supposed to see it.
    AndrewBit and Primus like this.
  5. Primus
    Offline

    Primus Notable Member

    Joined:
    Apr 7, 2015
    Posts:
    1,470
    Minecraft User:
    PrimusLV
    PHP:
    Level::addParticle(new FloatingTextParticle(), [Player])
  6. AndrewBit
    Offline

    AndrewBit Notable Member

    Joined:
    Jun 18, 2015
    Posts:
    435
    Minecraft User:
    AndrewBit4
    And there is anyway to hide it again?
  7. SOFe
    Offline

    SOFe Banned

    Joined:
    May 28, 2016
    Posts:
    386
    Minecraft User:
    Herobrine
    <?=
    str_replace("this helpful topic", "https://forums.pocketmine.net/threads/remove-particle.11325/",
    str_replace("<User>", "@AndrewBit", <<<EOM
    "<User> maybe you should use the Wiki etc", "Try googling this helpful topic", "Here's the completed code
    maybe you can learn from it :) "

    EOM
    )) ?>
  8. AndrewBit
    Offline

    AndrewBit Notable Member

    Joined:
    Jun 18, 2015
    Posts:
    435
    Minecraft User:
    AndrewBit4
    Well, I mean how to hide it for a specific player.

    By the way, what's the point of use str_replace instead tell me it directly? :rolleyes:
  9. rinkuno
    Offline

    rinkuno Active Member

    Joined:
    Oct 8, 2014
    Posts:
    59
    Minecraft User:
    rinku
    Can I get full code I have been searching for hours
  10. Extreme_Heat
    Offline

    Extreme_Heat Active Member

    Joined:
    Apr 19, 2016
    Posts:
    76
    Minecraft User:
    Extreme_Heat
    You need to send the specific players a RemoveEntityPacket which is going to require you to know the entity ID of the FloatingTextParticle (it's not really a particle, it's actually just an invisible mob).

    Since the $entityId aspect of FloatingTextParticle is protected, you're not going to be able to easily get (or even set) the entity ID.

    So you have 2 options:
    * Spawn the entity yourself and manage everything yourself, like who receives the packets
    * Break things using reflection
  11. SOFe
    Offline

    SOFe Banned

    Joined:
    May 28, 2016
    Posts:
    386
    Minecraft User:
    Herobrine
    Same as the link I linked you to, except that you have to add an extra parameter for both calls to Level::addParticle().
    Look at this:
    So just change addParticle($this->particle) to addParticle($this->particle, [$player]).

    The content inside the Heredoc is a quote from @iamadpond in his hammer thread to properly ask people to search.

    P.S. I can never remember whith one is Heredoc and which one is Nowdoc without checking it on php.net every time.
  12. Extreme_Heat
    Offline

    Extreme_Heat Active Member

    Joined:
    Apr 19, 2016
    Posts:
    76
    Minecraft User:
    Extreme_Heat
    Oh, I thought he wanted to hide FloatingTextParticle after already displaying it to a player.
  13. Extreme_Heat
    Offline

    Extreme_Heat Active Member

    Joined:
    Apr 19, 2016
    Posts:
    76
    Minecraft User:
    Extreme_Heat
    Er, FloatingTextParticle.php seems to already take care of removing the entity so you're right. I glanced over it a bit too quick ;).

Share This Page

Advertisement