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

Not Executed ?

Comments in 'Plugin Development' started by Ritch, Mar 25, 2016.

  1. Ritch
    Offline

    Ritch Active Member

    Joined:
    Oct 4, 2015
    Posts:
    184
    Minecraft User:
    anonymous
    For $event->setQuiMessage(); it work And count() not work why ? Not Executed i not have message error of my log.

    PHP:
           public function PlayerQuit(PlayerQuitEvent $event){
            
    $player $event->getPlayer();
            
    $lvl $player->getLevel()->getName();
              if(
    $lvl === "test"){
            if(isset(
    $this->players[$player->getName()])){   
                unset(
    $this->players[$player->getName()]);
                
    $event->setQuitMessage("[GAME] ".$player->getName()." Disconnected !");
                
    $this->refreshSign();
                if(
    count($this->players)< 1){
                    foreach(
    $this->players as $p){
                    
    $p->sendMessage("you are won !");
                    
    $p->teleport($this->getServer()->getLevelByName("world")->getSafeSpawn());
                    
    $p->setNameTag($p->getName());
                    
    $p->getInventory()->clearAll();
                    
    $this->min 4;
                    }
                    }
  2. MyNameIsTriXz
    Offline

    MyNameIsTriXz Notable Member

    Joined:
    Aug 17, 2015
    Posts:
    538
    Minecraft User:
    MyNameIsTriXz
    First, the player isnt fully unregistered on quit event, means that the level count is outdated, and how can you send to 0 players a messsge, do < 3 not < 1 (I use < 3 in my plugin too)
  3. Ritch
    Offline

    Ritch Active Member

    Joined:
    Oct 4, 2015
    Posts:
    184
    Minecraft User:
    anonymous
    Example of code Please ! :)
  4. CraftYourBukkit
    Offline

    CraftYourBukkit Notable Member Plugin Developer

    Joined:
    Jan 20, 2015
    Posts:
    1,022
    Plugins:
    2
    Minecraft User:
    CraftYourBukkit
    Why even <? Simply check if it's equal 1.
    applqpak likes this.
  5. Ritch
    Offline

    Ritch Active Member

    Joined:
    Oct 4, 2015
    Posts:
    184
    Minecraft User:
    anonymous
    Do you have code For solved my problem please And your win Like +1 ? Please
  6. xBeastMode
    Offline

    xBeastMode Active Member

    Joined:
    Nov 27, 2015
    Posts:
    292
    Because you are checking if there are zero players. Just change 'if(count ($players) < 1)' to 'if(count ( $players ) <= 1)'
    applqpak and Ritch like this.
  7. Ritch
    Offline

    Ritch Active Member

    Joined:
    Oct 4, 2015
    Posts:
    184
    Minecraft User:
    anonymous
    Indefined : $players ......
    What is the différent with if(count($this->players) < 1){ or if(count($this->players) > 1){ ?
  8. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    To debug which point of the code is run and which point is not run, try adding lines of echo at different places in your code.
    applqpak likes this.
  9. xBeastMode
    Offline

    xBeastMode Active Member

    Joined:
    Nov 27, 2015
    Posts:
    292
    Ritch... You were behind the last one at the distribution of brains.
    applqpak likes this.
  10. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    The difference is called "common sense". Or "eye test". Or "do-you-live-in-20th-to-21st-century test".
    applqpak likes this.
  11. Ritch
    Offline

    Ritch Active Member

    Joined:
    Oct 4, 2015
    Posts:
    184
    Minecraft User:
    anonymous
    OMG ! Lol example if(count($this->player) > 1){ = 1
    And if(count($this->players) < 1){ = 0 ... Okay .... I have other problem with code the problem is as a player quit and other players teleport in the Spawn with Message executed "You are won" all players help....
  12. Nawaf_Craft1b
    Offline

    Nawaf_Craft1b Active Member Plugin Developer

    Joined:
    May 8, 2015
    Posts:
    232
    Plugins:
    1
    Minecraft User:
    Nawaf_Craft1b
    PHP:
           public function PlayerQuit(PlayerQuitEvent $event){
            
    $player $event->getPlayer();
            
    $lvl $player->getLevel()->getName();
              if(
    $lvl === "test"){
            if(isset(
    $this->players[$player->getName()])){   
                unset(
    $this->players[$player->getName()]);
                
    $event->setQuitMessage("[GAME] ".$player->getName()." Disconnected !");
                
    $this->refreshSign();
                if(
    count($this->players) == 1){
                    foreach(
    $this->players as $pl){
    $p $this->getServer()->getPlayer($pl);
                    
    $p->sendMessage("you are won !");
                    
    $p->teleport($this->getServer()->getLevelByName("world")->getSafeSpawn());
                    
    $p->setNameTag($p->getName());
                    
    $p->getInventory()->clearAll();
                    
    $this->min 4;
                    }
                    }
  13. MyNameIsTriXz
    Offline

    MyNameIsTriXz Notable Member

    Joined:
    Aug 17, 2015
    Posts:
    538
    Minecraft User:
    MyNameIsTriXz
    Use == 2 as I said the player isnt fully unregistered on PlayerQuitEvent, so the player count is not correctly
  14. Nawaf_Craft1b
    Offline

    Nawaf_Craft1b Active Member Plugin Developer

    Joined:
    May 8, 2015
    Posts:
    232
    Plugins:
    1
    Minecraft User:
    Nawaf_Craft1b
    He Say
    PHP:
    foreach($this->players as $p){

    $p->sendMessage("..");
    etc..
    I Just Fix IT
    PHP:
     foreach($this->players as $pl){
    $p $this->getServer()->getPlayer($pl);
    $p->sendMessage("you are won !");
    etc..
  15. CraftYourBukkit
    Offline

    CraftYourBukkit Notable Member Plugin Developer

    Joined:
    Jan 20, 2015
    Posts:
    1,022
    Plugins:
    2
    Minecraft User:
    CraftYourBukkit
    Guess why. Because we do not know what your array looks like. It's not our fault if we expect the array to be another one than you really have.
    PEMapModder likes this.
  16. Nawaf_Craft1b
    Offline

    Nawaf_Craft1b Active Member Plugin Developer

    Joined:
    May 8, 2015
    Posts:
    232
    Plugins:
    1
    Minecraft User:
    Nawaf_Craft1b
    What Do You Mean !
    And Iam Just Edit IN Ritch Code TO Fix it..
  17. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    And how exactly do you know that $this->players is a string array not a Player[]?

Share This Page

Advertisement