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

Mechanics

Comments in 'Plugin Development' started by FlamingGenius, Sep 29, 2015.

  1. FlamingGenius
    Offline

    FlamingGenius Active Member

    Joined:
    Sep 23, 2015
    Posts:
    173
    Minecraft User:
    FlamingGenius
    I just coded this off the top of my head not sure how correct or wrong it might be

    PHP:

    public function checkPlayers(){
    $lobby $this->getConfig()->get("lobby");

    $players $this->getServer()->getLevelByName($lobby)->getOnlinePlayers();
      
    count($players);

    $min $this->getConfig()->get("min-players");

      if(
    $players >= $min){
       
    //code
      
    }

    }
    Edit
    I think this is more relaible i guess and neater
    PHP:
     public function onLobbyJoin(){
      
    $lobby $this->getConfig()->get("lobby-world");
      
    $players $this->getServer()->getLevelByName($lobby)->getOnlinePlayers();
      
    $min $this->getConfig()->get("min-players");
      if(
    count($players) >= $min){
      }
     }
    Last edited: Sep 29, 2015
  2. CraftYourBukkit
    Offline

    CraftYourBukkit Notable Member Plugin Developer

    Joined:
    Jan 20, 2015
    Posts:
    1,022
    Plugins:
    2
    Minecraft User:
    CraftYourBukkit
    That should work, yes
  3. FlamingGenius
    Offline

    FlamingGenius Active Member

    Joined:
    Sep 23, 2015
    Posts:
    173
    Minecraft User:
    FlamingGenius
    No faults? IN YOUR FACE @Gamecrafter :cool::D
  4. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    The function getOnlinePlayers doesn't exist in the Level class. Please read the documentation and/or source code of PocketMine. If you don't understand what they mean, learn PHP.
    RekkuzaRage likes this.
  5. Vaivez66
    Offline

    Vaivez66 Notable Member Plugin Developer

    Joined:
    Jun 10, 2015
    Posts:
    402
    Plugins:
    2
    Do u hate Gamecrafter?
  6. zombie_Power
    Offline

    zombie_Power Active Member

    Joined:
    Sep 7, 2015
    Posts:
    239
    Minecraft User:
    Zombie_Power
    How do you remember all these functions? o_O
    I looked through the source codes (pocketmine master), there are so many XD
  7. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    These are a few fundamental ones that you remember them after using for a few times. If you aren't sure, use an IDE, which has autocompletion and prediction.
    CrazedMiner likes this.
  8. Hotshot_9930
    Offline

    Hotshot_9930 Notable Member Plugin Developer

    Joined:
    May 26, 2014
    Posts:
    665
    Plugins:
    2
    Minecraft User:
    HotshotHD
    You remember alot through time.
  9. FlamingGenius
    Offline

    FlamingGenius Active Member

    Joined:
    Sep 23, 2015
    Posts:
    173
    Minecraft User:
    FlamingGenius
    Nah hes a pretty chill guy lol i dont have no issues with him i just pick on him bc hes always criticing everything i do :D
  10. Gamecrafter
    Offline

    Gamecrafter

    Joined:
    Nov 20, 2014
    Posts:
    978
    Plugins:
    9
    No, you should thoroughly read through the code if you're going to tell him. There is no Level::getOnlinePlayers(). :p
    There are mistakes. Too bad for you this time... :p
    He doesn't hate me. :) I'm too awesome to be hated on. :D
    Don't worry, you'll remember most if not all the essential ones in time. ;)
    I don't really see you "picking" on me. It's more like me "picking" on you. :p Anyways the cycle goes on.
  11. Hotshot_9930
    Offline

    Hotshot_9930 Notable Member Plugin Developer

    Joined:
    May 26, 2014
    Posts:
    665
    Plugins:
    2
    Minecraft User:
    HotshotHD
    Also the correct way to get the players in a level is Level::getPlayers();
  12. FlamingGenius
    Offline

    FlamingGenius Active Member

    Joined:
    Sep 23, 2015
    Posts:
    173
    Minecraft User:
    FlamingGenius
    I knew that i just wanted to see if YALL knew that;)
  13. Hotshot_9930
    Offline

    Hotshot_9930 Notable Member Plugin Developer

    Joined:
    May 26, 2014
    Posts:
    665
    Plugins:
    2
    Minecraft User:
    HotshotHD
    Sweet cover up :p
  14. Gamecrafter
    Offline

    Gamecrafter

    Joined:
    Nov 20, 2014
    Posts:
    978
    Plugins:
    9
    Cover up? :p Nope. We notable members know it's a cover-up when we see one.
  15. FlamingGenius
    Offline

    FlamingGenius Active Member

    Joined:
    Sep 23, 2015
    Posts:
    173
    Minecraft User:
    FlamingGenius
    Notable member: (adj)
    People who have nothing better to do then stalk the pocketmine forums
    :p
    PEMapModder likes this.
  16. zombie_Power
    Offline

    zombie_Power Active Member

    Joined:
    Sep 7, 2015
    Posts:
    239
    Minecraft User:
    Zombie_Power
    lol I am having trouble trying to find out where they are and how they work:(
  17. Hotshot_9930
    Offline

    Hotshot_9930 Notable Member Plugin Developer

    Joined:
    May 26, 2014
    Posts:
    665
    Plugins:
    2
    Minecraft User:
    HotshotHD
    Read the pocketmine source code to see how they work. Also look at plugins and see how other people have used them.
  18. zombie_Power
    Offline

    zombie_Power Active Member

    Joined:
    Sep 7, 2015
    Posts:
    239
    Minecraft User:
    Zombie_Power
    Thanks :)

Share This Page

Advertisement