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

addParticle() problem

Discussion in 'Development' started by XFizzer, Feb 16, 2017.

  1. XFizzer

    XFizzer Spider

    Messages:
    13
    GitHub:
    xfizzer
    PHP:
    public function spawnHolo()
        {
            
    $level $this->getServer()->getLevelByName("Spawn");
            
    $holo $this->getConfig();
            
    $x $holo->get("X");
            
    $y $holo->get("Y");
            
    $z $holo->get("Z");
            
    $text $holo->get("TEXT");
            
    $particle = new FloatingTextParticle(new Vector3($x$y$z), $text);
            
    $level->addParticle($particle);
        }
    Error "Call to a member function addParticle() on null""

    Can anyone help me to get the text to spawn
     
  2. kaliiks

    kaliiks Zombie

    Messages:
    250
    Level is not loaded or dont exist try $this->getServer()->loadLevel("Spawn"); in enable function
     
  3. XFizzer

    XFizzer Spider

    Messages:
    13
    GitHub:
    xfizzer
    Nope did work

    I also have $this->spawnHolo(); onEnable
     
  4. kaliiks

    kaliiks Zombie

    Messages:
    250
    Are u loading level before spawning holo?
     
  5. XFizzer

    XFizzer Spider

    Messages:
    13
    GitHub:
    xfizzer
  6. kaliiks

    kaliiks Zombie

    Messages:
    250
    Do if($this->getServer()->getLevelByName("Spawn")->isLevelLoaded()){
    $this->spawnHolo();
    }
    }
     
  7. XFizzer

    XFizzer Spider

    Messages:
    13
    GitHub:
    xfizzer
    Got this error
    Call to undefined method pocketmine\level\Level::isLevelLoaded()
     
  8. BEcraft

    BEcraft Slime

    Messages:
    79
    GitHub:
    BEcraft
    Maybe try:
    PHP:
    if($this->getServer()->isLevelLoaded("/*your world*/")){
    $this->spawnHolo();
    }
     
  9. corytortoise

    corytortoise Skeleton

    Messages:
    825
    GitHub:
    corytortoise
    If you haven't resolved the issue yet, can you share your config file with us?
     
  10. XFizzer

    XFizzer Spider

    Messages:
    13
    GitHub:
    xfizzer
    Didn't work
     
  11. XFizzer

    XFizzer Spider

    Messages:
    13
    GitHub:
    xfizzer
     
  12. BEcraft

    BEcraft Slime

    Messages:
    79
    GitHub:
    BEcraft
    Ok but what kind of "didnt work" is?
    I meant its still giving errors or the particle doesnt spawn?
     
  13. XFizzer

    XFizzer Spider

    Messages:
    13
    GitHub:
    xfizzer
    It didn't give any errors but it's not spawning
     
  14. corytortoise

    corytortoise Skeleton

    Messages:
    825
    GitHub:
    corytortoise
    Try removing the "" around the Y and restarting your server.
     
  15. XFizzer

    XFizzer Spider

    Messages:
    13
    GitHub:
    xfizzer
    Already tried didn't work
     
    Last edited: Feb 17, 2017
  16. corytortoise

    corytortoise Skeleton

    Messages:
    825
    GitHub:
    corytortoise
    Hm. Could you share your file structure or the entire plugin?
     
  17. XFizzer

    XFizzer Spider

    Messages:
    13
    GitHub:
    xfizzer
    What's your email? It's kinda of a private plugin
     
  18. wolfdale

    wolfdale Zombie Pigman

    Messages:
    535
    GitHub:
    diamond-gold
    Try and use this, see what it says in console
    PHP:
    var_dump($this->getServer()->isLevelLoaded("Spawn"));
     
  19. XFizzer

    XFizzer Spider

    Messages:
    13
    GitHub:
    xfizzer
    Didn't say anything
     
  20. wolfdale

    wolfdale Zombie Pigman

    Messages:
    535
    GitHub:
    diamond-gold
    It should show either true or false on console, check if your code is executed
     
  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.