Stop game when all players had Died?

Discussion in 'Development' started by Hoyee, Jun 14, 2020.

  1. Hoyee

    Hoyee Baby Zombie

    Messages:
    111
    If players all had died, I want to stop running minigame. How can I embody it?
    I think it should be yaml. isn't it?
     
  2. Emirhan Akpınar

    Emirhan Akpınar Slime

    Messages:
    86
    GitHub:
    EmirhanWSD
    Store who join the game in arena data. Remove player from arena data when death. Check if all player die with task.
     
  3. Diduhless

    Diduhless Baby Zombie

    Messages:
    158
    GitHub:
    Diduhless
    Why would you need a task for that? You could just check if there are no remaining players when someone dies.
     
    Heisenburger69 and Mohagames205 like this.
  4. Hoyee

    Hoyee Baby Zombie

    Messages:
    111
    then How can I make code of sense if players are null in YAML?
     
  5. Diduhless

    Diduhless Baby Zombie

    Messages:
    158
    GitHub:
    Diduhless
    Speak english properly please, there's no need to store players in a .yaml you could just save them into an array for each match
     
  6. Doxestic

    Doxestic Silverfish

    Messages:
    22
    you can also check the players of a world this is an example for you:
    PHP:
    public function onDeath(PlayerDeathEvent $ev){
            if (
    $ev->getPlayer()->getLevel()->getName() == "your world name"){
                
    $players  $this->getServer()->getLevelByName("your world name")->getPlayers();
                if (
    count($players) === 0){
                    
    //no alive player in this level...
                
    }
            }
        }
     

Share This Page

  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.