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

Particles Error

Discussion in 'Development' started by ZackyVN, Jan 15, 2019.

  1. ZackyVN

    ZackyVN Baby Zombie

    Messages:
    150
    I have this code
    Main:
    PHP:
    <?php

    namespace Wings;

    use 
    pocketmine\plugin\PluginBase;
    use 
    pocketmine\command\Command;
    use 
    pocketmine\command\CommandSender;
    use 
    pocketmine\command\ConsoleCommandSender;
    use 
    Wings\Tasks\{GreenWingHeartWingRedCircleYellowCircleBlueCircleGreenCircle};
    use 
    pocketmine\Player;
    use 
    pocketmine\event\Listener;
    use 
    pocketmine\event\player\PlayerQuitEvent;

    class 
    Main extends PluginBase implements Listener{

        public 
    $tasks = [];
        public 
    $wing1 = [];
        public 
    $wing2 = [];

        public function 
    onEnable () : void{
            
    $this->getServer()->getLogger()->info("§l§aHero§bMC§e>§r§a Wings Enable");
            
    $this->getServer()->getPluginManager()->registerEvents($this$this);
        }

        public function 
    onCommand(CommandSender $senderCommand $cmdstring $label, array $args) : bool{
            if (
    $cmd == "wing"){
                if(empty(
    $args[0]) || empty($args[1])){
                    
    $sender->sendMessage("§9•§4 Circle Red. §e/wing circlered <on|off>");
                    
    $sender->sendMessage("§9•§e Circle Yellow. §e/wing circleyellow <on|off>");
                    
    $sender->sendMessage("§9•§b Circle Blue. §e/wing circleblue <on|off>");
                    
    $sender->sendMessage("§9•§a Circle Green. §e/wing circlegreen <on|off>");
                    
    $sender->sendMessage("§9•§a Wing Green §e/wing green <on|off>");
                    
    $sender->sendMessage("§9•§c Wing Heart. §e/wing heart <on|off>");
                return 
    true;
            }
                if(!empty(
    $args[0])){
                    switch(
    $args[0]){
                        case 
    "green":
                            if(!
    $sender->hasPermission("green.wing")){
                                
    $sender->sendMessage("§l§aHero§bMC§e>§r§c Bạn không có quyền dùng Wing §aGreen");
                            return 
    true;
                        }
                            if(
    $args[1] == "on"){
                                
    $name $sender->getName();
                                    if(!
    in_array($name$this->wing1)){
                                        
    $this->wing1[] = $name;
                                        
    $sender->sendMessage("§l§aHero§bMC§e>§r§a Đã bật Wing Green");
                                    }else{
                                        
    $sender->sendMessage("Đã bật wing r");
    //                                        if(in_array($name, $this->plugin->particle3)) {
    //                                            unset($this->plugin->particle3[array_search($name, $this->plugin->particle3)]);
    //                                        }elseif(in_array($name, $this->plugin->particle2)) {
    //                                            unset($this->plugin->particle2[array_search($name, $this->plugin->particle2)]);
    //                                        }elseif(in_array($name, $this->plugin->particle4)) {
    //                                            unset($this->plugin->particle4[array_search($name, $this->plugin->particle4)]);
    //                                        }elseif(in_array($name, $this->plugin->particle1)) {
    //                                            unset($this->plugin->particle1[array_search($name, $this->plugin->particle1)]);
    //                                        }elseif(in_array($name, $this->plugin->particle5)) {
    //                                            unset($this->plugin->particle5[array_search($name, $this->plugin->particle5)]);
    //                                        }elseif(in_array($name, $this->plugin->particle6)) {
    //                                            unset($this->plugin->particle6[array_search($name, $this->plugin->particle6)]);
    //                                        }elseif(in_array($name, $this->plugin->particle7)) {
    //                                            unset($this->plugin->particle7[array_search($name, $this->plugin->particle7)]);
    //                                        }elseif(in_array($name, $this->plugin->particle9)) {
    //                                            unset($this->plugin->particle9[array_search($name, $this->plugin->particle9)]);
    //                                        }
    //                                    }
                                    
    }
                                if(
    $args[1] == "off"){
                                        unset(
    $this->wing1[array_search($name$this->wing1)]);
                                        
    $sender->sendMessage("§l§aHero§bMC§e>§r§c Đã tắt Wing §aGreen");
                                }
                    }
                        break;
                        default:
                    
    $sender->sendMessage("§9•§4 Circle Red. §e/wing circlered <on|off>");
                    
    $sender->sendMessage("§9•§e Circle Yellow. §e/wing circleyellow <on|off>");
                    
    $sender->sendMessage("§9•§b Circle Blue. §e/wing circleblue <on|off>");
                    
    $sender->sendMessage("§9•§a Circle Green. §e/wing circlegreen <on|off>");
                    
    $sender->sendMessage("§9•§a Wing Green §e/wing green <on|off>");
                    
    $sender->sendMessage("§9•§c Wing Heart. §e/wing heart <on|off>");
                            break;
                    }
                }
            }
            return 
    true;
        }
       }
    Task:
    PHP:
    <?php

    namespace Wings\Tasks;

    use 
    Wings\Main;
    use 
    pocketmine\scheduler\Task;
    use 
    pocketmine\level\particle\HappyVillagerParticle;
    use 
    pocketmine\Player;
    use 
    pocketmine\math\Vector3;

    class 
    GreenWing extends Task{

        public function 
    __construct(Main $plugin){
            
    $this->plugin $plugin;
            
    $this->plugin->getScheduler()->scheduleRepeatingTask($this10);
        }

        public function 
    onRun(int $currentTick){
            foreach(
    $this->plugin->getServer()->getOnlinePlayers() as $player) {
                
    $name $player->getName();
            if(
    in_array($name$this->plugin->wing1)){
         
    $center = new Vector3($x$y 2.5$z);
        
    $particle = new HappyVillagerParticle($center);
        for(
    $yaw 0$yaw <= 10$yaw += (M_PI 2) / 20){
        
    $x = -sin($yaw) + $center->x;
        
    $z cos($yaw) + $center->z;
        
    $y $center->y;
        
    $particle->setComponents($x$y$z);
        
    $level->addParticle($particle);           
    Everything work fine but when i type /wing green on it doesnt do anything and the /wing green off too!
    It must send a message but nope it doesnt send anything
     
  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.