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

Solved PluginTask Issue

Comments in 'Plugin Development' started by TryoneLegendZzz, Jul 24, 2015.

  1. TryoneLegendZzz
    Offline

    TryoneLegendZzz Active Member

    Joined:
    May 31, 2015
    Posts:
    201
    Minecraft User:
    SavionLegendZzz
    Ok I Am Using A PluginTask To Send A Pop Up But It Keeps Saying "call to member function sendPopUp()"
    Here Is My Code
    PHP:
    <?php
    namespace ServerCore;

    use 
    pocketmine\Server;
    use 
    pocketmine\Player;
    use 
    pocketmine\scheduler\PluginTask;

    class 
    PluginTask extends PluginTask {
        public function 
    __construct($plugin){
            
    $this->plugin $plugin;
            
    parent::__construct($plugin);
        }

        public function 
    onRun($tick){
            
    $this->getOwner()->getServer()->getOnlinePlayers()->sendPopUp(" §5§l[MysticalCraftPE]§2Welcome To This Server!");
    }
    }
  2. Legoboy0215
    Offline

    Legoboy0215 Notable Member

    Joined:
    Nov 1, 2014
    Posts:
    1,724
    Minecraft User:
    Legoboy0215
    Because getOnlinePlayers() is an array. foreach it then sendPopup.
    Last edited: Jul 24, 2015
  3. RekkuzaRage
    Offline

    RekkuzaRage Active Member

    Joined:
    Apr 15, 2014
    Posts:
    251
    Minecraft User:
    RekkuzaRage
    Yep it is suppose to be...
    PHP:
    foreach($this->getServer()->getOnlinePlayers() as $p) {
    $p->sendPopup("Hello world.");
    }
    Last edited: Jul 24, 2015
  4. Legoboy0215
    Offline

    Legoboy0215 Notable Member

    Joined:
    Nov 1, 2014
    Posts:
    1,724
    Minecraft User:
    Legoboy0215
    Forgot to add the getOnlinePlayers()
  5. TryoneLegendZzz
    Offline

    TryoneLegendZzz Active Member

    Joined:
    May 31, 2015
    Posts:
    201
    Minecraft User:
    SavionLegendZzz
    Thanks This Worked!
    Legoboy0215 likes this.
  6. Legoboy0215
    Offline

    Legoboy0215 Notable Member

    Joined:
    Nov 1, 2014
    Posts:
    1,724
    Minecraft User:
    Legoboy0215
    Of course it will. Read the Docs...
  7. RekkuzaRage
    Offline

    RekkuzaRage Active Member

    Joined:
    Apr 15, 2014
    Posts:
    251
    Minecraft User:
    RekkuzaRage
    Oops typo!
  8. mamayadesu
    Offline

    mamayadesu Active Member Plugin Developer

    Joined:
    Sep 19, 2013
    Posts:
    146
    Plugins:
    4
    Minecraft User:
    mamayadesu
    Да, тупо :D (Forget about it :) )

Share This Page

Advertisement