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

players in game detect spectator ?

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

  1. Ritch
    Offline

    Ritch Active Member

    Joined:
    Oct 4, 2015
    Posts:
    184
    Minecraft User:
    anonymous
    hi guys, how in fact , when the player loses, he can go spectator and when he left two players in the world and kills another person then detects the player spectator ? How to avoid this?

    #SorryForMyBadEnglish
    PHP:
         public function onBlockSpectator(BlockBreakEvent $event) {
         
    $player $event->getPlayer();
            
    $block $event->getBlock();
            
    $level $player->getLevel()->getName();
            
    $spec $this->cfg->get("sign_spec");
            if(
    $level === $spec){
            if(
    $block->getFloorX() === $this->cfg->get("spec_x") | $block->getFloorY() === $this->cfg->get("spec_y") | $block->getFloorZ() === $this->cfg->get("spec_z")){
            
    $player->sendMessage("§6[§bGAME§6] §5» §7you are spectator !");
             
    $this->getServer()->loadLevel("test");
            
    $player->teleport($this->getServer()->getLevelByName("test")->getSafeSpawn());
            if(
    $level === "test"){
             
    $this->getServer()->broadcastMessage("§6[§bGAME§6] §5» §7".$player->getName()." join Spectator !");
             
    $player->setGamemode(3);
             
    $player->setDisplayName("§c[Spectator] ".$player->getName()."");
        }
         }
         }
         
    //code for spectator . How To unset as player won
  2. AndrewBit
    Offline

    AndrewBit Notable Member

    Joined:
    Jun 18, 2015
    Posts:
    435
    Minecraft User:
    AndrewBit4
    Spectators can't break blocks.
  3. Ritch
    Offline

    Ritch Active Member

    Joined:
    Oct 4, 2015
    Posts:
    184
    Minecraft User:
    anonymous
    Why ? Break for join sign spectator . You dont help me :( help me please... How unset player spectator as player won GAME .
  4. Ritch
    Offline

    Ritch Active Member

    Joined:
    Oct 4, 2015
    Posts:
    184
    Minecraft User:
    anonymous
  5. AndrewBit
    Offline

    AndrewBit Notable Member

    Joined:
    Jun 18, 2015
    Posts:
    435
    Minecraft User:
    AndrewBit4
    I can't help you because I can't understand you.

    If you're trying to set spectators gamemode to another one...
    Get all players and check one by one if their gamemode is spectator, if it's, set their gamemode to another one. How difficult is that?
  6. Ritch
    Offline

    Ritch Active Member

    Joined:
    Oct 4, 2015
    Posts:
    184
    Minecraft User:
    anonymous
    Do you have code For help me ? Please
  7. Ritch
    Offline

    Ritch Active Member

    Joined:
    Oct 4, 2015
    Posts:
    184
    Minecraft User:
    anonymous
    I 'm not talking about the gamemode 3 but the remaining players are in survival the other players can join the game in spectator to see how the winner to avoid check if ( count ($ this-> players) 1) { while there as the viewer?
  8. Legoboy0215
    Offline

    Legoboy0215 Notable Member

    Joined:
    Nov 1, 2014
    Posts:
    1,724
    Minecraft User:
    Legoboy0215
    Create another array saving everyone who died. Then count all players in game subtracted by all inside the head array.
  9. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    Look at the Matches API in DynamicHub.
    Ritch likes this.
  10. Ritch
    Offline

    Ritch Active Member

    Joined:
    Oct 4, 2015
    Posts:
    184
    Minecraft User:
    anonymous
    Link ?
  11. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
  12. Ritch
    Offline

    Ritch Active Member

    Joined:
    Oct 4, 2015
    Posts:
    184
    Minecraft User:
    anonymous
    Wow ! This code is hard for me ...

Share This Page

Advertisement