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

Wait seconds

Comments in 'Plugin Development' started by TheLucyClub, Apr 19, 2015.

  1. TheLucyClub
    Offline

    TheLucyClub Banned

    Joined:
    Jan 31, 2015
    Posts:
    53
    Minecraft User:
    iCreepyKid
    How to make plugin wait? $p->sendPopup("STuf"); wait 1 seconds $p->sendPopup("more Stuf");
    How do this? Help please me!
  2. TheLucyClub
    Offline

    TheLucyClub Banned

    Joined:
    Jan 31, 2015
    Posts:
    53
    Minecraft User:
    iCreepyKid
    Urgent help pls!
  3. hoyinm14mc
    Offline

    hoyinm14mc Notable Member Plugin Developer

    Joined:
    Jun 4, 2014
    Posts:
    502
    Plugins:
    9
    Minecraft User:
    hoyinm14mc
    Use ScheduleDelayedTask
    PEMapModder and TonyDroidd like this.
  4. TheLucyClub
    Offline

    TheLucyClub Banned

    Joined:
    Jan 31, 2015
    Posts:
    53
    Minecraft User:
    iCreepyKid
    Sorry, I newbie this stuff :p
  5. TonyDroidd
    Offline

    TonyDroidd Active Member

    Joined:
    Sep 6, 2014
    Posts:
    180
    Minecraft User:
    TonyDroidd
    an example? please
  6. TheLucyClub
    Offline

    TheLucyClub Banned

    Joined:
    Jan 31, 2015
    Posts:
    53
    Minecraft User:
    iCreepyKid
    Yes, please example providen! I need plugin is essential!
  7. Goerick
    Offline

    Goerick Active Member

    Joined:
    Jan 24, 2014
    Posts:
    252
    Minecraft User:
    goerick
    it takes time for people to be active 9n this forum, read your post and comment.
  8. TheLucyClub
    Offline

    TheLucyClub Banned

    Joined:
    Jan 31, 2015
    Posts:
    53
    Minecraft User:
    iCreepyKid
    Can you help?
  9. hoyinm14mc
    Offline

    hoyinm14mc Notable Member Plugin Developer

    Joined:
    Jun 4, 2014
    Posts:
    502
    Plugins:
    9
    Minecraft User:
    hoyinm14mc
    PHP:
    //Main.php
    if(blah blah){
      
    $this->getServer()->getScheduler()->scheduleDelayedTask(new Task($this$player), 40); //show for 2 seconds
    }
    //Task.php
    public function onRun($tick){
      switch(
    $tick){
        case 
    1:
          
    $this->player->sendPopup("HI");
        case 
    10:
          
    $this->player->sendPopup("HI");
        case 
    20:
          
    $this->player->sendPopup("HI");
        case 
    30:
          
    $this->player->sendPopup("HI");
          
    //cancel the task at last
          
    $this->getServer()->getScheduler()->cancelTask($this->getTaskId());
      }
    }
    Last edited: Apr 20, 2015
  10. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,325
    Plugins:
    11
    Minecraft User:
    PEMapModder
    I'm not sure if $tick is server tick or your own task's tick...
  11. hoyinm14mc
    Offline

    hoyinm14mc Notable Member Plugin Developer

    Joined:
    Jun 4, 2014
    Posts:
    502
    Plugins:
    9
    Minecraft User:
    hoyinm14mc
    Server tick
  12. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,325
    Plugins:
    11
    Minecraft User:
    PEMapModder
    So is it appropriate to use it in your example code? What if the task isn't scheduled on the first tick?m
  13. hoyinm14mc
    Offline

    hoyinm14mc Notable Member Plugin Developer

    Joined:
    Jun 4, 2014
    Posts:
    502
    Plugins:
    9
    Minecraft User:
    hoyinm14mc
    Then idk lol
  14. Falk
    Offline

    Falk Staff Member Global Moderator

    Joined:
    Sep 2, 2013
    Posts:
    1,710
    Plugins:
    22
    Minecraft User:
    Falkirknh
    Main code (in your PluginBase)
    let $player be an instance of pocketmine\Player
    PHP:
    $player->sendPopup("Stuff");
    $this->getServer()->getScheduler()->scheduleDelayedTask(new MoreStuffTask($this$player), 20); // There are 20 ticks in a second
    The MoreStuffTask
    PHP:
    class MoreStuffTask extends PluginTask{
        private 
    $player;
        public function 
    __construct($plugin$player){
            
    parent::__construct($plugin);
            
    $this->player $player;
        }
        public function 
    onRun($tick){
            
    $this->player->sendPopup("More stuff");
        }   
    }
    hoyinm14mc and PEMapModder like this.

Share This Page

Advertisement