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

Check Players in PlayerQuitEvent

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

  1. Ritch
    Offline

    Ritch Active Member

    Joined:
    Oct 4, 2015
    Posts:
    184
    Minecraft User:
    anonymous
    Hi guys, How To check a player quit ingame ? And check winner
    #SorryForMyBadEnglish
  2. minebuilder0110
    Offline

    minebuilder0110 Notable Member

    Joined:
    Dec 8, 2014
    Posts:
    485
    Minecraft User:
    Apparitional
    Get who have left the server in the PlayerQuitEvent, then check if player is in game (I don't know your system, do this yourself).
  3. Primus
    Offline

    Primus Notable Member

    Joined:
    Apr 7, 2015
    Posts:
    1,470
    Minecraft User:
    PrimusLV
    How do we know your plugin structure/outline ?
    applqpak likes this.
  4. Ritch
    Offline

    Ritch Active Member

    Joined:
    Oct 4, 2015
    Posts:
    184
    Minecraft User:
    anonymous
    Sorry look this...
    PHP:
            public function onQuit(PlayerQuitEvent $event){
            
    $player $event->getPlayer();
               
    $lvl $playet->getLevel()->getName();
                if(
    $lvl === "test"){
                  unset(
    $this->players[$player->getName()]);
                   
    $event->setQuitMessage("§l§c§o[GAME] ".$player->getName()." quit game !");
       
                if(
    count($this->players) <= 1){
                 if(
    count($this->players) === 1){    
                     foreach(
    $this->players as $p){
                    
    $p->sendMessage("§l§6won game  !");
                    
    $this->getServer()->loadLevel("world");
                       
    $p->teleport($this->getServer()->getLevelByName("world")->getSafeSpawn());
                       
    $p->setNameTag($p->getName());
                       
    $p->getInventory()->clearAll();
                       
    $this->min 20;
                    }
                     }
                    } 
  5. minebuilder0110
    Offline

    minebuilder0110 Notable Member

    Joined:
    Dec 8, 2014
    Posts:
    485
    Minecraft User:
    Apparitional
    Can you tell me what is not working? Errors?
    Also:
    1. Unless you are planning to use one game per plugin, I recommend having a similar structure like this:
    players:
    arenaname:
    - Someone
    - SomeoneElse
    arenaname2:
    - Toby
    - Jack

    2.
    if(count($this->players) <= 1){
    if(count($this->players) === 1){
    Why double-check?
    KubixQ, applqpak, Ritch and 2 others like this.
  6. Ritch
    Offline

    Ritch Active Member

    Joined:
    Oct 4, 2015
    Posts:
    184
    Minecraft User:
    anonymous
    Crash dump getSpawn() on null ...
  7. minebuilder0110
    Offline

    minebuilder0110 Notable Member

    Joined:
    Dec 8, 2014
    Posts:
    485
    Minecraft User:
    Apparitional
    I cannot find that here.
  8. Ritch
    Offline

    Ritch Active Member

    Joined:
    Oct 4, 2015
    Posts:
    184
    Minecraft User:
    anonymous
    I Need help please :(
  9. minebuilder0110
    Offline

    minebuilder0110 Notable Member

    Joined:
    Dec 8, 2014
    Posts:
    485
    Minecraft User:
    Apparitional
    How are we supposed to help you without proper information?
  10. Ritch
    Offline

    Ritch Active Member

    Joined:
    Oct 4, 2015
    Posts:
    184
    Minecraft User:
    anonymous
    And .... foreach($this-players as $p){
    Not work too :( why i not have chance :(
  11. Irish
    Offline

    Irish Active Member

    Joined:
    Apr 24, 2016
    Posts:
    96
    Minecraft User:
    _Irish_
    You spelled $player as $playet on $lvl,
    Primus likes this.
  12. Irish
    Offline

    Irish Active Member

    Joined:
    Apr 24, 2016
    Posts:
    96
    Minecraft User:
    _Irish_
    Can't find anything else wrong with it, but that should be why the getSpawn is returning null.
    Primus and Ritch like this.
  13. Ritch
    Offline

    Ritch Active Member

    Joined:
    Oct 4, 2015
    Posts:
    184
    Minecraft User:
    anonymous
    Code Please ?
  14. CraftYourBukkit
    Offline

    CraftYourBukkit Notable Member Plugin Developer

    Joined:
    Jan 20, 2015
    Posts:
    1,022
    Plugins:
    2
    Minecraft User:
    CraftYourBukkit
    Dude, just read..
    Primus likes this.
  15. Ritch
    Offline

    Ritch Active Member

    Joined:
    Oct 4, 2015
    Posts:
    184
    Minecraft User:
    anonymous
    Sorry i am noob in English thank
  16. MyNameIsTriXz
    Offline

    MyNameIsTriXz Notable Member

    Joined:
    Aug 17, 2015
    Posts:
    538
    Minecraft User:
    MyNameIsTriXz
    As I told you, the player count is on PlayerQuitEvent outdated, so when the count on quit is 2, then there is only 1 player in the world.
    Ritch likes this.
  17. Ritch
    Offline

    Ritch Active Member

    Joined:
    Oct 4, 2015
    Posts:
    184
    Minecraft User:
    anonymous
    Thank carebears :)

Share This Page

Advertisement