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

message not work or detect....

Comments in 'Plugin Development' started by Ritch, Apr 8, 2016.

  1. Ritch
    Offline

    Ritch Active Member

    Joined:
    Oct 4, 2015
    Posts:
    184
    Minecraft User:
    anonymous
    Message not work why ? Or not detect ?

    PHP:
       public function onPlayerDeath(PlayerDeathEvent $event){
         
    $player $event->getEntity();
        
    $lastAttack $player->getLastDamageCause();
        if(
    $lastAttack instanceof EntityDamageByEntityEvent){
         
    $attacker $lastAttack->getDamager();
            
    $victim $lastAttack->getEntity();
        
    $counter count($this->getServer()->getOnlinePlayers());
                
    $lvl $player->getLevel()->getName();
                   if(
    $lvl === "test"){
                    if(isset(
    $this->players[$player->getName()])){   
                      unset(
    $this->players[$player->getName()]);
                      if(isset(
    $this->spectator[$player->getName()])){
                    unset(
    $this->spectator[$player->getName()]);
                      
    $victim->sendMessage(TextFormat::RED"§l§c[GAME] You are died  ".$victim->getName()." !");
                        
    $victim->getInventory()->clearAll();                              
                         
    $victim->setGamemode(0);
                    
    $victim->setNameTag($victim->getName());

                   if(
    count($this->players) <= 1){
                    foreach(
    $this->players as $p){   
                    
    $p->sendMessage("§l§6you have +2 point !");
                    
    $this->getServer()->broadcastMessage("§o§9[GAME] {$p->getName()} won a game !");
                    
    $p->teleport($this->getServer()->getLevelByName("world")->getSafeSpawn());
                    
    $p->setNameTag($p->getName());
                    
    $p->getInventory()->clearAll();
                    
    $this->removeSpectator($this->spectator[$sp->getName]);           
                    }
                    }
                        }
                        }
                        }
                        }
                   
               
    $name $this->cfg->get("reset_map");
               if (!
    $this->getServer()->getLevelByName($name) instanceof Level) {
                    
    $this->deleteDirectory($this->getServer()->getDataPath() . "/worlds/" $name);
                    
    $this->copymap($this->getDataFolder() . "/maps/" $name$this->getServer()->getDataPath() . "/worlds/" $name);
                    
    $this->getServer()->loadLevel($name);
                } else {
                    
    $this->getServer()->unloadLevel($this->getServer()->getLevelByName($name));
                    
    $this->deleteDirectory($this->getServer()->getDataPath() . "/worlds/" $name);
                    
    $this->copymap($this->getDataFolder() . "/maps/" $name$this->getServer()->getDataPath() . "/worlds/" $name);
                    
    $this->getServer()->loadLevel($name);
                      foreach(
    $this->getServer()->getLevels() as $levels){
                
    $tiles $this->getServer()->getLevelByName("world")->getTile(new Vector3(624115));
                  if(
    $tiles instanceof Sign){
                    if ((
    $world $this->getServer()->getLevelByName("test"))){
                      
    $count count($world->getPlayers());
                       if(
    $this->gameStarted === true){
                        
    $tiles->setText("§l§6[GAME]""§l§bJoin !""[$count/8]""");
                        
    $this->refreshSign();          
                      }
                      }
                      }
                   unset(
    $this->start);
                   unset(
    $this->timer);
                   unset(
    $this->min);
                      }
                      }
                      }
  2. MCPEPIG
    Offline

    MCPEPIG Notable Member

    Joined:
    Jun 22, 2014
    Posts:
    349
    Minecraft User:
    MCPEPIG
    Do you get any errors?
  3. Ritch
    Offline

    Ritch Active Member

    Joined:
    Oct 4, 2015
    Posts:
    184
    Minecraft User:
    anonymous
    No... :/
  4. MCPEPIG
    Offline

    MCPEPIG Notable Member

    Joined:
    Jun 22, 2014
    Posts:
    349
    Minecraft User:
    MCPEPIG
    Did you register events?
  5. Ritch
    Offline

    Ritch Active Member

    Joined:
    Oct 4, 2015
    Posts:
    184
    Minecraft User:
    anonymous
    Yes.. The problem is message not work or not detect. I not know problem....
  6. MCPEPIG
    Offline

    MCPEPIG Notable Member

    Joined:
    Jun 22, 2014
    Posts:
    349
    Minecraft User:
    MCPEPIG
    You should add
    PHP:
    strtolower($player->getName())
    to
    PHP:
    $this->players[$player->getName()]
    &
    PHP:
    $this->spectator[$player->getName()]
  7. xBeastMode
    Offline

    xBeastMode Active Member

    Joined:
    Nov 27, 2015
    Posts:
    292
    Ugly format and I can't understand what you mean.
    PHP:
    public function onPlayerDeath(PlayerDeathEvent $event){
        
    $player $event->getEntity();
        
    $lastAttack $player->getLastDamageCause();
        if(
    $lastAttack instanceof EntityDamageByEntityEvent){
            
    $attacker $lastAttack->getDamager();
            
    $victim $lastAttack->getEntity();
            
    $counter count($this->getServer()->getOnlinePlayers());
            
    $lvl $player->getLevel()->getName();
            if(
    $lvl === "test"){
                if(isset(
    $this->players[$player->getName()])){
                    unset(
    $this->players[$player->getName()]);
                    if(isset(
    $this->spectator[$player->getName()])){
                        unset(
    $this->spectator[$player->getName()]);
                        
    $victim->sendMessage(TextFormat::RED"§l§c[GAME] You are died  ".$victim->getName()." !");
                        
    $victim->getInventory()->clearAll();
                        
    $victim->setGamemode(0);
                        
    $victim->setNameTag($victim->getName());

                        if(
    count($this->players) <= 1){
                            foreach(
    $this->players as $p){
                                
    $p->sendMessage("§l§6you have +2 point !");
                                
    $this->getServer()->broadcastMessage("§o§9[GAME] {$p->getName()} won a game !");
                                
    $p->teleport($this->getServer()->getLevelByName("world")->getSafeSpawn());
                                
    $p->setNameTag($p->getName());
                                
    $p->getInventory()->clearAll();
                                
    $this->removeSpectator($this->spectator[$sp->getName]);
                            }
                        }
                    }
                }
            }
        }

        
    $name $this->cfg->get("reset_map");
        if (!
    $this->getServer()->getLevelByName($name) instanceof Level) {
            
    $this->deleteDirectory($this->getServer()->getDataPath() . "/worlds/" $name);
            
    $this->copymap($this->getDataFolder() . "/maps/" $name$this->getServer()->getDataPath() . "/worlds/" $name);
            
    $this->getServer()->loadLevel($name);
        } else {
            
    $this->getServer()->unloadLevel($this->getServer()->getLevelByName($name));
            
    $this->deleteDirectory($this->getServer()->getDataPath() . "/worlds/" $name);
            
    $this->copymap($this->getDataFolder() . "/maps/" $name$this->getServer()->getDataPath() . "/worlds/" $name);
            
    $this->getServer()->loadLevel($name);
            foreach(
    $this->getServer()->getLevels() as $levels){
                
    $tiles $this->getServer()->getLevelByName("world")->getTile(new Vector3(624115));
                if(
    $tiles instanceof Sign){
                    if ((
    $world $this->getServer()->getLevelByName("test"))){
                        
    $count count($world->getPlayers());
                        if(
    $this->gameStarted === true){
                            
    $tiles->setText("§l§6[GAME]""§l§bJoin !""[$count/8]""");
                            
    $this->refreshSign();
                        }
                    }
                }
                unset(
    $this->start);
                unset(
    $this->timer);
                unset(
    $this->min);
            }
        }
    }
    MCPEPIG likes this.

Share This Page

Advertisement