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

Cancel event with ScheduleRepeatingTask

Comments in 'Plugin Development' started by Artide, Sep 12, 2015.

  1. Artide
    Offline

    Artide Active Member

    Joined:
    Apr 20, 2015
    Posts:
    214
    Minecraft User:
    Artide5
    How do I cancel an event for example in hunger games, cancel PlayerMoveEvent when the timer is over.
    Last edited: Sep 12, 2015
  2. Gamecrafter
    Offline

    Gamecrafter

    Joined:
    Nov 20, 2014
    Posts:
    978
    Plugins:
    9
    Learn PHP, and all your questions will be answered.
  3. Artide
    Offline

    Artide Active Member

    Joined:
    Apr 20, 2015
    Posts:
    214
    Minecraft User:
    Artide5
    I don't care what you say.
    Andrey Nazarchuk likes this.
  4. Gamecrafter
    Offline

    Gamecrafter

    Joined:
    Nov 20, 2014
    Posts:
    978
    Plugins:
    9
    You are trying to make plugins without knowing PHP. BTW if you didn't care, you wouldn't have replied. :p
  5. Hotshot_9930
    Offline

    Hotshot_9930 Notable Member Plugin Developer

    Joined:
    May 26, 2014
    Posts:
    665
    Plugins:
    2
    Minecraft User:
    HotshotHD
    Just make a config with something like "Task: enabled"
    When the timer gets to 0 use the task to switch it to "disabled".

    In the event do:
    PHP:
    If($taskConfig == "disabled") {
      
    $event->setCancelled(true);
    }
    You can also do it using dynamic arrays.
    Last edited: Sep 12, 2015
  6. RekkuzaRage
    Offline

    RekkuzaRage Active Member

    Joined:
    Apr 15, 2014
    Posts:
    251
    Minecraft User:
    RekkuzaRage
    I would use arrays, it would be much faster.
    Hotshot_9930 likes this.
  7. Primus
    Offline

    Primus Notable Member

    Joined:
    Apr 7, 2015
    Posts:
    1,470
    Minecraft User:
    PrimusLV
    just
    PHP:
    public $timer;
    timer:
    PHP:
    public function onRun($currentTick){
    if(
    $currentTick >= 300){
    $this->owner->timer false// Disabled
    }
    }
  8. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    Just use time() and compare the time at different places.
  9. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    Can you stop targetting people? Just assume you don't know whether the questioner knows PHP and answer directly.


    When a match starts, save the time. So in PlayerMoveEvent, if time() - $startTime < 30, cancel the event.

    You don't need to use scheduler for this.
    RekkuzaRage likes this.
  10. CaptainKenji17
    Offline

    CaptainKenji17 Active Member

    Joined:
    Apr 22, 2014
    Posts:
    252
    Minecraft User:
    CaptainKenji17
    well gamecrafter, people's here are not asking for "learn php" "that's impossible" "make your own plugin" and I think you better stop replying you're just trying to get hate
    Creeperface and PEMapModder like this.
  11. Hotshot_9930
    Offline

    Hotshot_9930 Notable Member Plugin Developer

    Joined:
    May 26, 2014
    Posts:
    665
    Plugins:
    2
    Minecraft User:
    HotshotHD
    Its a really annoying thing to say and I hate when people on these forums say it. If you don't have anything that can actually help the person other than "Learn PHP" just don't say anything at all.
    RekkuzaRage and PEMapModder like this.
  12. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    Indeed. It was a fun phrase to use initially, but now you are abusing it so much you ruined all the fun, @Gamecrafter.
    xFlare, RekkuzaRage and Hotshot_9930 like this.
  13. Gamecrafter
    Offline

    Gamecrafter

    Joined:
    Nov 20, 2014
    Posts:
    978
    Plugins:
    9
    Well, sorry for ruining the fun, I'll come up with something new. Learn HTML(which has nothing to do with PHP).
    CaptainKenji17 and Hotshot_9930 like this.
  14. Gamecrafter
    Offline

    Gamecrafter

    Joined:
    Nov 20, 2014
    Posts:
    978
    Plugins:
    9
    Life is always more exciting when you have people hating on you. *takes out flamethrower*
  15. Hotshot_9930
    Offline

    Hotshot_9930 Notable Member Plugin Developer

    Joined:
    May 26, 2014
    Posts:
    665
    Plugins:
    2
    Minecraft User:
    HotshotHD
    No one is hating.
    All I was saying is that people come to get help and spamming "learn php" is not helpful at all.
    Plus its getting old and annoying.
  16. Gamecrafter
    Offline

    Gamecrafter

    Joined:
    Nov 20, 2014
    Posts:
    978
    Plugins:
    9
    Yes, it does help. Some people come in here knowing only a little HTML and they're saying they want to make a PocketMine plugin, and the last time I checked, was written in PHP.
    Primus likes this.
  17. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    So can you just assume that they know PHP and help directly? We encourage but cannot force people to learn PHP. I myself never officially learnt PHP but got to how I am today by using my brain and looking at examples.
    Creeperface likes this.
  18. Artide
    Offline

    Artide Active Member

    Joined:
    Apr 20, 2015
    Posts:
    214
    Minecraft User:
    Artide5
    Hey im getting an error.
    [00:59:49] [Server thread/CRITICAL]: Could not execute task HG\Timer: Argument 1 passed to HG\Main::eek:nBlockBreak() must be an instance of pocketmine\event\block\BlockBreakEvent, null given, called in C:\Users\Jesus\Downloads\PocketMine-MP\plugins\HG\src\HG\Timer.php on line 35 and defined
    [00:59:49] [Server thread/NOTICE]: InvalidArgumentException: "Argument 1 passed to HG\Main::eek:nBlockBreak() must be an instance of pocketmine\event\block\BlockBreakEvent, null given, called in C:\Users\Jesus\Downloads\PocketMine-MP\plugins\HG\src\HG\Timer.php on line 35 and defined" (E_RECOVERABLE_ERROR) in "/HG/src/HG/Main" at line 127
  19. Creeperface
    Offline

    Creeperface Notable Member Plugin Developer

    Joined:
    Nov 8, 2014
    Posts:
    1,346
    Plugins:
    4
    Minecraft User:
    CreeperFace
    you "can't" run "event" method in a task.
  20. Primus
    Offline

    Primus Notable Member

    Joined:
    Apr 7, 2015
    Posts:
    1,470
    Minecraft User:
    PrimusLV
    Why does Jesus uses your PC not mine ? :(

Share This Page

Advertisement