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

What Wrong Code ??

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

  1. PmServer
    Offline

    PmServer New Member

    Joined:
    May 7, 2015
    Posts:
    53
    Minecraft User:
    PmServer
    PHP:
    <?php
    //problem help
    namespace CountPlayer;

    use 
    pocketmine\scheduler\PluginTask;
    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->getServer()->getScheduler()->scheduleRepeatingTask(new Timer($this), 60);
            
    $this->getLogger()->info(C::GREEN."CountPlayer Has Enable !");
    }}
    class 
    Timer extends PluginTask {

        public function 
    __construct(Main $plugin) {
            
    $this->plugin $plugin;
            
    parent::__construct($plugin);
         }

        public function 
    onRun($tick) {
            
    $this->plugin->sec--;
                foreach(
    $this->plugin->getServer()->getOnlinePlayers() as $players) {     
                    
    $players->sendPopup("[Game] Start in ".$this->plugin->sec." second(s) !");
                       if(
    $this->plugin->sec === 0){
                        
    $players->sendPopup("[lGame] Started !! Gogo !");
    $this->plugin->getServer()->getScheduler()->cancelTask($this->getHandler()->getTaskId());
                        unset (
    $this->plugin->sec);


               
    }}}}
    what wrong my code ???
  2. CraftYourBukkit
    Offline

    CraftYourBukkit Notable Member Plugin Developer

    Joined:
    Jan 20, 2015
    Posts:
    1,022
    Plugins:
    2
    Minecraft User:
    CraftYourBukkit
    Mind telling us the Error?
  3. Nawaf_Craft1b
    Offline

    Nawaf_Craft1b Active Member Plugin Developer

    Joined:
    May 8, 2015
    Posts:
    232
    Plugins:
    1
    Minecraft User:
    Nawaf_Craft1b
    PHP:
    public $sec /*Time*/;
  4. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    $this->plugin->sec is not initialized.
    Also, why are you calling the iterating variable $players? The variable only contains one player each time; that'd make it quite confusing.

Share This Page

Advertisement