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

What Wrong My Code ?? :$

Comments in 'Plugin Development' started by PmServer, Mar 3, 2016.

  1. PmServer
    Offline

    PmServer New Member

    Joined:
    May 7, 2015
    Posts:
    53
    Minecraft User:
    PmServer
    what wrong my code ?
    PHP:
    <?php

    namespace CountPlayer;

    use 
    pocketmine\plugin\PluginBase;
    use 
    pocketmine\event\Listener;
    use 
    pocketmine\Player;
    use 
    pocketmine\utils\TextFormat as C;

    class 
    Main extends PluginBase implements Listener {
        public function 
    onEnable() {
            
    $this->getServer()->getPluginManager()->registerEvents($this$this);
            
    $this->getLogger()->info(C::GREEN."CountPlayer Has Enable !");
        }
        public function 
    Count(Player $player) {
            if(
    count($player) == 1){
                
    $player->sendMessage("Welcome !");
            }
        }
    }
  2. AndrewBit
    Offline

    AndrewBit Notable Member

    Joined:
    Jun 18, 2015
    Posts:
    435
    Minecraft User:
    AndrewBit4
    What is that code trying to do? It has not point.
    PHP:
    public function OnJoin(PlayerJoinEvent $event)
    {
    #Idk what are you trying, but maybe this is what you want.
    if(count(($players $this->getServer()->getLevelByName("world")->getPlayers())) == 1){
    foreach(
    $players as $p){
    $p->sendMessage("Welcome...?");
    }
    }
  3. PmServer
    Offline

    PmServer New Member

    Joined:
    May 7, 2015
    Posts:
    53
    Minecraft User:
    PmServer
    PHP:
    public function OnJoin(Player $event)
    {
    #Idk what are you trying, but maybe this is what you want.
    if(count(($players $this->getServer()->getLevelByName("world")->getPlayers())) == 1){
    foreach(
    $players as $p){
    $p->sendMessage("Welcome...?");
    }
    }
    its work ?
    @AndrewBit
  4. AndrewBit
    Offline

    AndrewBit Notable Member

    Joined:
    Jun 18, 2015
    Posts:
    435
    Minecraft User:
    AndrewBit4
    Why you change the argument 1 to "Player"? I think that you need learn a lot about PocketMine API...
    And maybe PHP >.<
  5. PmServer
    Offline

    PmServer New Member

    Joined:
    May 7, 2015
    Posts:
    53
    Minecraft User:
    PmServer
    No iwant Make Minigames on Task :)
    Do you Plugin minigames with Task ?
  6. Hotshot_9930
    Offline

    Hotshot_9930 Notable Member Plugin Developer

    Joined:
    May 26, 2014
    Posts:
    665
    Plugins:
    2
    Minecraft User:
    HotshotHD
    Of course it doesn't work. All you did was create a function. Nothing will happen unless you actually use the function.
    Nawaf_Craft1b and PEMapModder like this.
  7. JackboyPlay
    Offline

    JackboyPlay Active Member

    Joined:
    Apr 25, 2015
    Posts:
    507
    Minecraft User:
    JackboyPlay
    No I've hacked your PC and made it so that it doesn't work on your PC...
  8. basprohop
    Offline

    basprohop Active Member Plugin Developer

    Joined:
    Aug 8, 2015
    Posts:
    128
    Plugins:
    3
    Minecraft User:
    basprohop
    By the look of your code you don't seem to know php, you should learn it first before you attempt to make a minigame.
    Hotshot_9930 likes this.
  9. JackboyPlay
    Offline

    JackboyPlay Active Member

    Joined:
    Apr 25, 2015
    Posts:
    507
    Minecraft User:
    JackboyPlay
    The fish in the bowl knows all things!
  10. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    Sorry, but I fail to see the relationship between learning PHP and the problem of this thread.

Share This Page

Advertisement