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

[New API] Timer

Comments in 'Plugin Development' started by ArtMik, Jun 12, 2014.

  1. ArtMik
    Offline

    ArtMik New Member

    Joined:
    Feb 22, 2014
    Posts:
    18
    Minecraft User:
    ArtMik
    I read the new documentation and can not understand how to use the schedule. Can you help?
  2. Killman2
    Offline

    Killman2 Active Member Plugin Developer

    Joined:
    May 5, 2014
    Posts:
    81
    Plugins:
    1
    Minecraft User:
    Killman2
    $this->getServer()->getScheduler()->scheduleDelayedTask(
    new MyCallbackPluginTask(array($this, "delayedFunction"), array("item 0", "item 1"), $this), 1200);
    $this->getServer()->getScheduler()->scheduleRepeatedTask(
    new MyCallbackPluginTask(array($this, "repeatedFunction"), array("item 2", "item 3"), $this), 700);
    That's how you create a schedule for the new API.
  3. ArtMik
    Offline

    ArtMik New Member

    Joined:
    Feb 22, 2014
    Posts:
    18
    Minecraft User:
    ArtMik
    Что означают array("item 2", "item 3"), ?
    Если пользоваться режимом "тупо скопировать", то не робит.

    ___

    does not work
    Last edited: Jun 14, 2014
    Killman2 likes this.
  4. xpyctum
    Offline

    xpyctum Active Member Plugin Developer

    Joined:
    Jan 13, 2014
    Posts:
    292
    Plugins:
    4
    Minecraft User:
    tylerdisney
    Прост))
  5. ArtMik
    Offline

    ArtMik New Member

    Joined:
    Feb 22, 2014
    Posts:
    18
    Minecraft User:
    ArtMik
    У меня на это ругается MyCallbackPluginTask

    ____

    class MyCallbackPluginTask not available
  6. xpyctum
    Offline

    xpyctum Active Member Plugin Developer

    Joined:
    Jan 13, 2014
    Posts:
    292
    Plugins:
    4
    Minecraft User:
    tylerdisney
    Скинь полный код. Посмотрим
  7. ArtMik
    Offline

    ArtMik New Member

    Joined:
    Feb 22, 2014
    Posts:
    18
    Minecraft User:
    ArtMik
    Code:

    $this->getServer()->getScheduler()->scheduleRepeatedTask(

    new MyCallbackPluginTask(array($this, "repeatedFunction"), array("item 2", "item 3"), $this), 700);

    Text error:

    Fatal error: Call to a member function onRun() on a non-object in /root/src/pocketmine/scheduler/TaskHandler.php on line 136
    Fatal error: Call to a member function onCancel() on a non-object in /root/src/pocketmine/scheduler/TaskHandler.php on line 122


    Суть ошибок понятна, туда передается не объект.
    The essence of the error is understandable, there is no object is passed.
  8. xpyctum
    Offline

    xpyctum Active Member Plugin Developer

    Joined:
    Jan 13, 2014
    Posts:
    292
    Plugins:
    4
    Minecraft User:
    tylerdisney
    Ты в папке создал файл: repeartedFunction.php?
    И код плагина, а не ошибки :)
  9. ArtMik
    Offline

    ArtMik New Member

    Joined:
    Feb 22, 2014
    Posts:
    18
    Minecraft User:
    ArtMik
    нет, стой, а резве это не public function repeartedFunction(){} писать надо?
  10. iJoshuaHD
    Offline

    iJoshuaHD Notable Member Plugin Developer

    Joined:
    Nov 7, 2013
    Posts:
    1,196
    Plugins:
    4
    Minecraft User:
    iJoshuaHD
    this is not in an international forum. please and thank you :)

    (but seriously, we need to know how this new schedule works xD)
    Darunia18 and xktiverz like this.
  11. Killman2
    Offline

    Killman2 Active Member Plugin Developer

    Joined:
    May 5, 2014
    Posts:
    81
    Plugins:
    1
    Minecraft User:
    Killman2
    О боже, значит не судьба тебе понять…это же так легко
  12. Tiemo2000
    Offline

    Tiemo2000 Active Member

    Joined:
    Nov 23, 2013
    Posts:
    86
    Minecraft User:
    Tiemo2000
    You can get banned from talking another language
  13. xpyctum
    Offline

    xpyctum Active Member Plugin Developer

    Joined:
    Jan 13, 2014
    Posts:
    292
    Plugins:
    4
    Minecraft User:
    tylerdisney
    Sorry, MineMik. Это тебе за то что новус в топ не поместил ><
    No, new api must used classes.
    Create repeartedFunction.php in plugin folder
    And use
    PHP:
    public function onRun($currentTick){
    Server::getInstance()->broadcastMessage("test");
    }
    In repeartedFunction.php
    Last edited: Jun 14, 2014
  14. ArtMik
    Offline

    ArtMik New Member

    Joined:
    Feb 22, 2014
    Posts:
    18
    Minecraft User:
    ArtMik
    Ска пиндосы.
    Thanks for the help!
  15. xpyctum
    Offline

    xpyctum Active Member Plugin Developer

    Joined:
    Jan 13, 2014
    Posts:
    292
    Plugins:
    4
    Minecraft User:
    tylerdisney
    Try this. in this file add this
    MineMik.php
    PHP:
    <?php
    namespace MineMik;
    use 
    pocketmine\event\Listener;
    use 
    pocketmine\Player;
    use 
    pocketmine\plugin\PluginBase;
    use 
    pocketmine\Server;
    class 
    MainClass extends PluginBase implements ListenerCommandExecutor{
    public function 
    onLoad(){
    $this->getLogger()->info("loaded!");
    }
    public function 
    onEnable(){
    $time 3000;
    $this->getServer()->getScheduler()->scheduleRepeatingTask(new ScheldueTask($this), $time);
     }
    public function 
    onDisable(){
    $this->getLogger()->info("Disabled");
    }
    }
    And ScheldueTask.php
    PHP:
    <?php
    namespace MimeMik;
    use 
    pocketmine\Player;
    use 
    pocketmine\scheduler\PluginTask;
    use 
    pocketmine\Server;
    class 
    ScheldueTask extends PluginTask{
    public function 
    onRun($currentTick){
    Server::getInstance()->broadcastMessage("Hello!!!");
    }
    }
    args and ArtMik like this.
  16. Darunia18
    Offline

    Darunia18 Staff Member Sectional Moderator

    Joined:
    Aug 23, 2013
    Posts:
    755
    Plugins:
    2
    Minecraft User:
    Darunia18
    Moved to Plugin Development.
  17. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,306
    Plugins:
    11
    Minecraft User:
    PEMapModder
    You are using my schedule utils.

Share This Page

Advertisement