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

Plugin don't work

Discussion in 'Development' started by Jonas, Mar 2, 2017.

  1. Jonas

    Jonas Baby Zombie

    Messages:
    192
    This Plugin dosn't work.
    PHP:
    <?php

    use pocketmine\plugin\PluginBase;
    use 
    pocketmine\math\Vector3;
    use 
    pocketmine\level\particle\FlameParticle;
    use 
    pocketmine\scheduler\PluginTask;

    class 
    Main extends PluginBase {

        private 
    $radius 3;
        private 
    $particles 50;
        private 
    $location$level;
        private 
    $sphere false;

        public function 
    __construct(Location &$locationbool $sphere)
        {
            
    $this->level $location->getLevel();
            
    $this->location = &$location;
            
    $this->sphere $sphere;
        }

        private static function 
    getRandomVector() : Vector3
        
    {
            
    $x 0$y 0$z 0;
            
    $x = (float)rand()/(float)getrandmax() * 1;
            
    $y = (float)rand()/(float)getrandmax() * 1;
            
    $z = (float)rand()/(float)getrandmax() * 1;
            
    $v = new Vector3($x$y$z);
            return 
    $v->normalize();
        }

        public function 
    onRun($tick) {
            for (
    $i 0$i $this->particles; ++$i) {
                
    $vector self::getRandomVector()->multiply($this->radius);
                if (!
    $this->sphere) {
                    
    $vector->abs($vector->getY());
                }
                
    $this->level->addParticle(new FlameParticle($this->location->add($vector->x$vector->y$vector->z)));
                
    $this->location->add($vector->x$vector->y$vector->z);
            }
        }
    }
     
  2. robske_110 (Tim)

    robske_110 (Tim) Wither Skeleton Poggit Reviewer

    Messages:
    1,342
    GitHub:
    robske110
    Could you please please be more specific with your questions? 'Plugin don't work'+Code sounds like you want us to just fix everything and give it back to you. Include meaningful error messages, if any, or at least a description what doesn't work.

    And from what i can see you did just copy random bits of code together and punch them into a Main class extending PluginBase and you expect it to work/be classified as a plugin? __construct is not called with anything for plugins and onRun() is belonging to a PluginTask.
     
  3. Jonas

    Jonas Baby Zombie

    Messages:
    192
    This Plugin Create a sphere/hemisphere of particles but i dosn't work. It comes no Errors.
     
  4. Sandertv

    Sandertv Zombie Pigman Poggit Reviewer

    Messages:
    786
    GitHub:
    Sandertv
    That's because nothing is ever called. Put the code you have in a Repeating Task and schedule that task in onEnable.
     
  5. jasonwynn10

    jasonwynn10 Moderator Poggit Reviewer

    Messages:
    1,489
    GitHub:
    jasonwynn10
  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.