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

Error With ScheduleRepeatingTask

Comments in 'Plugin Development' started by PlayCubePE, May 30, 2015.

  1. PlayCubePE
    Offline

    PlayCubePE New Member

    Joined:
    Mar 19, 2015
    Posts:
    29
    Minecraft User:
    PlayCubePE
    Okay, PocketMine return me a parse error / syntax error and here's the code

    Task.php :

    PHP:
    <?php

    namespace hungergames\Task;

    use 
    pocketmine\scheduler\PluginTask;
    use 
    pocketmine\Server;
    use 
    pocketmine\Player;
    use 
    pocketmine\math\Vector3;
    use 
    pocketmine\level\Position;
    use 
    hungergames\Main;

    class 
    Task extends PluginTask {

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

      public function 
    onRun($currentTick){
    $this->plugin $this->getOwner();
        
    $this->plugin->minute++;

        if(
    $this->plugin->minute and $this->plugin->minute <= 5)

            {

                 
    $this->getServer()->broadcastMessage("----------------------------------------------------");

                 
    $this->getServer()->broadcastMessage("** Welcome to Hunger Games v1");

             
    $this->getServer()->broadcastMessage("** Current Players: ".count($this->getServer()->getOnlinePlayers())."/".$this->getServer()->getMaxClients);

             
    $this->getServer()->broadcastMessage("** Have Fun and Good Luck!");

             
    $this->getServer()->broadcastMessage("** [NOTE] You are supposed to be stuck before game start.");

                
    $this->getServer()->broadcastMessage("** ".($this->plugin->minute)." minutes left until the game starts.");

                 
    $this->getServer()->broadcastMessage("----------------------------------------------------");

            }


    if (
    $this->plugin->minute 5) {

    $this->plugin->startGame();

    }

    if(
    $this->plugin->minute and $this->plugin->minute 19)

            {

                 
    $this->getServer((($this->plugin->minute)." minutes left");
    if (
    count($this->getServer()->getOnlinePlayers <= 2)) {
    foreach(
    $this->getServer()->getOnlinePlayers as $lp) {
    $lp->kick("Congrats, you won the match!");
    }
    $this->getServer()->shutdown();

    }


            }

    if(
    $this->plugin->minute == 19)

            {

                
    $this->getServer()->broadcastMessage("1 minutes left. Spawning everyone to the spawn. Finish the game off!");

                foreach(
    $this->getServer()->getOnlinePlayers() as $p)

                {

                    
    $this->plugin->playerspawncount 0;

                    
    $nextspawn $this->plugin->getNextSpawn();

                    
    $p->teleport(new Vector3($nextspawn[0], $nextspawn[1], $nextspawn[2]));

                }

            }


        if(
    $this->plugin->minute === 20;){
          
    $this->plugin->getServer()->getScheduler()->cancelTask($this->plugin->taskId);
    foreach(
    $this->getServer()->getOnlinePlayers as $lp) {
    $lp->kick("Congrats, you won the match!");
    }
    $this->getServer()->shutdown();
        }
      }

    }

    ?>
    Main.php (Only the Schedule Part) :

    PHP:
    public function onEnable() {
    $this->getServer()->getPluginManager()->registerEvents($this$this);

    $this->task $this->getServer()->getScheduler()->scheduleRepeatingTask(new Task\Task($this), 1200);
    }
  2. luca28pet
    Offline

    luca28pet Active Member

    Joined:
    Feb 20, 2014
    Posts:
    251
    Minecraft User:
    luca28pet
    This is the right constructor:
    PHP:
    public function __construct(Main $plugin){
      
    parent::__construct($plugin);
       
    $this->plugin $plugin;
     }
    Also, in your Task class, replace $this->getServer() with $this->plugin->getServer()
    EvolSoft and CraftYourBukkit like this.
  3. PlayCubePE
    Offline

    PlayCubePE New Member

    Joined:
    Mar 19, 2015
    Posts:
    29
    Minecraft User:
    PlayCubePE
    Ok, i'll see if it works.
  4. PlayCubePE
    Offline

    PlayCubePE New Member

    Joined:
    Mar 19, 2015
    Posts:
    29
    Minecraft User:
    PlayCubePE
    Still getting this:

    [PocketMine] Server is starting...
    [PocketMine] Server was started.
    [Server] 07:09:43 [WARNING] Timezone could not be automatically determined. An incorrect timezone will result in incorrect timestamps on console logs. It has been set to "UTC" by default. You can change it on the php.ini file.
    [Server] string(37) "LOAD 32-bit version pocketmine/Server"
    [Server] 07:09:43 [INFO] Loading pocketmine.yml...
    [Server] 07:09:43 [INFO] Loading server properties...
    [Server] 07:09:43 [INFO] Selected English (eng) as the base language
    [Server] 07:09:43 [INFO] Starting Minecraft: PE server version v0.11.0 alpha
    [Server] 07:09:43 [NOTICE] The memory-limit setting has been deprecated.
    [Server] 07:09:43 [NOTICE] There are new memory settings on pocketmine.yml to tune memory and events.
    [Server] 07:09:43 [NOTICE] You can also reduce the amount of threads and chunks loaded control the memory usage.
    [Server] 07:09:43 [INFO] Opening server on 0.0.0.0:19132
    [Server] string(59) "LOAD 32-bit version pocketmine/network/protocol/LoginPacket"
    [Server] string(58) "LOAD 32-bit version pocketmine/network/protocol/DataPacket"
    [Server] "
    [Server] "
    [Server] "
    [Server] "
    [Server] "
    [Server] "
    [Server] "
    [Server] "
    [Server] 07:09:43 [INFO] This server is running PocketMine-MP version 1.5dev-1198 "活発(Kappatsu)フグ(Fugu)" (API 1.12.0)
    [Server] 07:09:43 [INFO] PocketMine-MP is distributed under the LGPL License
    [Server] "
    [Server] string(47) "LOAD 32-bit version raklib/server/ServerHandler"
    [Server] "
    [Server] "
    [Server] 07:09:46 [INFO] Loading DevTools v1.10.0
    [Server] 07:09:46 [INFO] Loading SimpleAuth v1.7.1
    [Server] 07:09:46 [INFO] Loading WalkingParticles v0.1
    [Server] 07:09:46 [INFO] Loading SexyMOTD v0.2
    [Server] 07:09:51 [INFO] ----- PocketMine-MP Auto Updater -----
    [Server] 07:09:51 [INFO] It appears you're running a Beta build, when you've specified that you prefer to run Stable builds.
    [Server] 07:09:51 [INFO] If you would like to be kept informed about new Beta or Development builds, it is recommended that you change 'preferred-channel' in your pocketmine.yml to 'beta' or 'development'.
    [Server] 07:09:51 [INFO] ----- -------------------------- -----
    [Server] 07:09:51 [INFO] Enabling DevTools v1.10.0
    [Server] 07:09:51 [INFO] Loading source plugin HungerGames v0.10.0
    [Server] 07:09:51 [INFO] [DevTools] Registered folder plugin loader
    [Server] 07:09:51 [INFO] Enabling SimpleAuth v1.7.1
    [Server] 07:09:51 [INFO] [SimpleAuth] Everything loaded!
    [Server] "
    [Server] "
    [Server] "
    [Server] "
    [Server] "
    [Server] "
    [Server] 07:09:51 [INFO] Preparing level "Hub"
    [Server] 07:09:51 [INFO] Enabling WalkingParticles v0.1
    [Server] 07:09:51 [INFO] [WalkingParticles] Loaded Successfully!
    [Server] 07:09:51 [INFO] Enabling SexyMOTD v0.2
    [Server] 07:09:51 [INFO] [SexyMOTD] Loaded Successfully!
    [Server] 07:09:51 [INFO] Enabling HungerGames v0.10.0
    [Server]
    [Server] Parse error: syntax error, unexpected '{' in /storage/sdcard0/PocketMine/plugins/Hunger Games/src/hungergames/Task/Task.php on line 12
    [Server] 07:09:51 [EMERGENCY] An unrecoverable error has occurred and the server has crashed. Creating a crash dump
    [Server] 07:09:51 [EMERGENCY] Please upload the "/storage/sdcard0/PocketMine/CrashDump_Sun_May_31-07.09.51-UTC_2015.log" file to the Crash Archive and submit the link to the Bug Reporting page. Give as much info as you can.
    [Server] 07:09:51 [INFO] Disabling DevTools v1.10.0
    [Server] 07:09:51 [INFO] Disabling SimpleAuth v1.7.1
    [Server] 07:09:51 [INFO] Disabling WalkingParticles v0.1
    [Server] 07:09:51 [INFO] Disabling SexyMOTD v0.2
    [Server] 07:09:51 [INFO] Disabling HungerGames v0.10.0
    [Server] 07:09:51 [INFO] Unloading level "Hub"
    [Server] "
    [Server] "
    [Server] zend_mm_heap corrupted
    [PocketMine] Server was stopped.

Share This Page

Advertisement