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

Help Anyone

Comments in 'Plugin Development' started by TryoneLegendZzz, Sep 26, 2015.

  1. TryoneLegendZzz
    Offline

    TryoneLegendZzz Active Member

    Joined:
    May 31, 2015
    Posts:
    201
    Minecraft User:
    SavionLegendZzz
    so i need help with PlayedInteractEvent. i am trying to add a player to an array when they do
    PHP:
    $ev->getAction() === RIGHT_CLICK_BLOCK
    but it seems to not notice the item (no console errors) any help?
  2. Gamecrafter
    Offline

    Gamecrafter

    Joined:
    Nov 20, 2014
    Posts:
    978
    Plugins:
    9
    Well at least post the full code. We're not mind readers. And can't you think of a better title than "Ok"?
  3. TryoneLegendZzz
    Offline

    TryoneLegendZzz Active Member

    Joined:
    May 31, 2015
    Posts:
    201
    Minecraft User:
    SavionLegendZzz
    lul
    PHP:
        public function getTeam(PlayerInteractEvent $event){
            
    $player=$event->getPlayer();
            
    $block=$event->getBlock();

            if(
    $this->PlayerIsInGame($player->getName()) && $player->getInventory()->getItemInHand() === new Item(351,1,1) && $event->getAction() === RIGHT_CLICK_BLOCK){

    if(
    count($this->redPlayer)===4){
    $this->addBluePlayer($player);
    $player->sendMessage("§cYou Have joined the blue team due to the red team was full!");
    }else{
    $this->addRedPlayer($player);
    $player->sendMessage("§8[§6TeamDeathMatch§8]§eYou have joined the red team!");
    }
    }
            if(
    $this->PlayerIsInGame($player->getName()) && $player->getInventory()->getItemInHand() === new Item(351,12,1) && $event->getAction() === RIGHT_CLICK_BLOCK ){

    if(
    count($this->bluePlayer)===4){
    $this->addRedPlayer($player);
    $player->sendMessage("§cYou Have joined the red team due to the blue team was full!");
    }else{
    $this->addBluePlayer($player);
    $player->sendMessage("§8[§6TeamDeathMatch§8]§eYou have joined the blue team!");
    }
    if(
    count($this->bluePlayer)===&& count($this->redPlayer)===4){
    $event->setCancelled(true);
    $player->sendMessage("All teams are full you have been removed from the game!");
                unset(
    $this->players[$event->getPlayer()->getName()]);
                                     
    $player->setLevel($this->signlevel);
                                     
    $player->teleport($this->signlevel->getSpawnLocation());
                        
    $player->getInventory()->clearAll();
                }
    }

    }
  4. Gamecrafter
    Offline

    Gamecrafter

    Joined:
    Nov 20, 2014
    Posts:
    978
    Plugins:
    9
    It's PlayerInteractEvent::RIGHT_CLICK_BLOCK not just RIGHT_CLICK_BLOCK. Please learn more about the difference between constants and magic constants: http://php.net/manual/en/language.constants.php
    CrazedMiner likes this.
  5. Legoboy0215
    Offline

    Legoboy0215 Notable Member

    Joined:
    Nov 1, 2014
    Posts:
    1,724
    Minecraft User:
    Legoboy0215
    I think he copied and paste :p.
  6. TryoneLegendZzz
    Offline

    TryoneLegendZzz Active Member

    Joined:
    May 31, 2015
    Posts:
    201
    Minecraft User:
    SavionLegendZzz
    oi
    no i have always done it this way
    Legoboy0215 likes this.
  7. Gamecrafter
    Offline

    Gamecrafter

    Joined:
    Nov 20, 2014
    Posts:
    978
    Plugins:
    9
    That's what I was thinking too. But don't tell him that... :p
    Legoboy0215 likes this.
  8. TryoneLegendZzz
    Offline

    TryoneLegendZzz Active Member

    Joined:
    May 31, 2015
    Posts:
    201
    Minecraft User:
    SavionLegendZzz
    oioioioioi
  9. Lambo
    Offline

    Lambo Notable Member Plugin Developer

    Joined:
    Sep 14, 2013
    Posts:
    431
    Plugins:
    4
    Minecraft User:
    Lambo
    In the future, you can just log the value.
    PHP:
     $this->getLogger()->info($event->getAction());
    CrazedMiner likes this.
  10. Legoboy0215
    Offline

    Legoboy0215 Notable Member

    Joined:
    Nov 1, 2014
    Posts:
    1,724
    Minecraft User:
    Legoboy0215
    Just use echo…
  11. FlamingGenius
    Offline

    FlamingGenius Active Member

    Joined:
    Sep 23, 2015
    Posts:
    173
    Minecraft User:
    FlamingGenius
    Echo works with plugins?
  12. Hotshot_9930
    Offline

    Hotshot_9930 Notable Member Plugin Developer

    Joined:
    May 26, 2014
    Posts:
    665
    Plugins:
    2
    Minecraft User:
    HotshotHD
    ...Pocketmine is written in PHP, therefore, all PHP functions work with plugins. (correct me if im wrong)
    the "echo" function in a plugin would show up as an "info" logger.
  13. FlamingGenius
    Offline

    FlamingGenius Active Member

    Joined:
    Sep 23, 2015
    Posts:
    173
    Minecraft User:
    FlamingGenius
    Ahhh see that makes sense im sitting here thinkin "wth would u use echo for"
  14. Legoboy0215
    Offline

    Legoboy0215 Notable Member

    Joined:
    Nov 1, 2014
    Posts:
    1,724
    Minecraft User:
    Legoboy0215
    No. It will show up as text like var_dump.
  15. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    var_dump is preferred over echo (actually, echo is a control structure, not a fucntion) for dumping values for debugging since it also reports the type of the value and shows boolean FALSE and NULL (echo will report nothing for NULL and boolean FALSE). Sometimes, this helps fix a lot of issues.
  16. Legoboy0215
    Offline

    Legoboy0215 Notable Member

    Joined:
    Nov 1, 2014
    Posts:
    1,724
    Minecraft User:
    Legoboy0215
    But don't people use echo in their final project, but no one leaves var_dumps all over the place?
  17. FlamingGenius
    Offline

    FlamingGenius Active Member

    Joined:
    Sep 23, 2015
    Posts:
    173
    Minecraft User:
    FlamingGenius
    Ive looked through a lot of plugins(for educatiom purposes) and i have never seen anyone use echo i saw a few use print_r and some use var_dump()
    Last edited: Sep 28, 2015
  18. aliuly
    Offline

    aliuly Notable Member Plugin Developer

    Joined:
    Feb 8, 2014
    Posts:
    1,086
    Plugins:
    17
    I myself use "echo" a lot. But then again, I also use print_r (and occasionally var_dump, when I also need to know the type).

    At any rate, it only means that you have several tools at your disposal, and it is your job to know what to use and when.

    And "echo" does work as long as you have a "console" available. For example, if you run on Linux. I have heard that if you are running your server on Android, the "echo"'s do not work.
  19. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    They forgot to remove it.

Share This Page

Advertisement