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

Solved Show players config from Particle Text

Discussion in 'Development' started by Zinkaio, May 7, 2018.

  1. Zinkaio

    Zinkaio Spider

    Messages:
    13
    GitHub:
    zinkaio
    So Im trying to make a floating particle text showing some of the players configs like for ex
    Your kills is : {Kills}
    but since the particle is send by like this:

    foreach($this->plugin->getServer()->getOnlinePlayers() as $p) {
    $this->PlayerFiles = Config stuff ya know
    $kills = $this->PlayerFiles->get("kills");
    $particletext= [
    "Your kills are: " . $kills]
    and then particle gets spawned and ya know what else happens so

    My pro is the particle shows ur stuff just as I want it but when a player joins for some reason it updates to that players config when it should only be showing mine only
     
  2. Zinkaio

    Zinkaio Spider

    Messages:
    13
    GitHub:
    zinkaio
    any ways to make sure when using:
    foreach($this->plugin->getServer()->getOnlinePlayers() as $p) {
    to get urself only?
     
  3. Zinkaio

    Zinkaio Spider

    Messages:
    13
    GitHub:
    zinkaio
  4. Zinkaio

    Zinkaio Spider

    Messages:
    13
    GitHub:
    zinkaio
    nvm I got it lol
     
  5. TwistedAsylumMC

    TwistedAsylumMC Slime

    Messages:
    96
    GitHub:
    twistedasylummc
    use PlayerJoinEvent, add the text to only the player by doing
    PHP:
    $kills $this->PlayerFiles->get("kills");
    $particletext "Your kills are: " $kills;
    $level $this->getServer()->getLevelByName("level name");
    $level->addParticle(new FloatingTextParticle(new Vector3($x$y$z), $particletext), [$player]);
     
  6. SOFe

    SOFe Administrator Staff Member PMMP Team Poggit Admin

    Messages:
    1,968
    GitHub:
    sof3
    Why don't you just get the level from the player, instead of hardcoding the level name?
     
  7. TwistedAsylumMC

    TwistedAsylumMC Slime

    Messages:
    96
    GitHub:
    twistedasylummc
    incase the player spawned in a different world than u want the text to be in
     
  8. SOFe

    SOFe Administrator Staff Member PMMP Team Poggit Admin

    Messages:
    1,968
    GitHub:
    sof3
    What's the point of showing the FloatingTextParticle in another level than the one the player is in?
    In addition, the $level object context actually has no effect on the particle displayed. See the implementation of addParticle(): $this is only used to get the list of players in the level if $players is not defined (which is not the case in the above code), or used to get the Server singleton instance, which is identical for every level.
     
  9. Zinkaio

    Zinkaio Spider

    Messages:
    13
    GitHub:
    zinkaio
    I tag this as "solved" and no @PotatoeTheDev that's bad coding, no no pls!!
     
  10. xXNiceAssassinlo YT

    xXNiceAssassinlo YT Zombie Pigman

    Messages:
    499
    GitHub:
    xXNiceYT
    Atleast that was a help
     
  11. SOFe

    SOFe Administrator Staff Member PMMP Team Poggit Admin

    Messages:
    1,968
    GitHub:
    sof3
    Got a problem with your Windows? Delete C:\Winfows\System32\ntoskrnl.exe; it will break your OS, but at least that is a help in assisting you stop seeing the problem.
     
  12. xXNiceAssassinlo YT

    xXNiceAssassinlo YT Zombie Pigman

    Messages:
    499
    GitHub:
    xXNiceYT
    No... I don’t wanna break my os
     
  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.