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

Sleep() alternative

Comments in 'Plugin Development' started by ChipsCrafterHD, Nov 27, 2016.

  1. ChipsCrafterHD
    Offline

    ChipsCrafterHD New Member

    Joined:
    Dec 28, 2015
    Posts:
    4
    Minecraft User:
    ChipsCrafterHD
    When i use Sleep() in my Plugin, the whole server "sleeps". How can i fix that? Here is my Code.
    PHP:
    <?php

    namespace derdumme\info;

    use 
    pocketmine\plugin\PluginBase;
    use 
    pocketmine\event\Listener;
    use 
    pocketmine\utils\TextFormat;
    use 
    pocketmine\event\player\PlayerJoinEvent;

    class 
    info extends PluginBase implements Listener {
      public function 
    onEnable() {
      
    $this->getLogger()->info(TextFormat::GREEN."wurde aktiviert.");
      
    $this->getServer()->getPluginManager()->registerEvents($this$this);
      }
      public function 
    onDisable() {
      
    $this->getLogger()->info(TextFormat::RED."wurde deaktiviert.");
      }
      public function 
    onJoin(PlayerJoinEvent $event){
      while(
    true) {
      
    $message random_int(15);
      if(
    $message == 1){
      
    $event->getPlayer()->sendPopup(TextFormat::GREEN."Teamspeak-Server: ts.skyzonemc.net");
      } elseif (
    $message == 2) {
      
    $event->getPlayer()->sendPopup(TextFormat::GOLD."Website: SkyZoneMC.net");
      } elseif (
    $message == 3) {
      
    $event->getPlayer()->sendTip("This is a Tip");
      }
      
    sleep(60);
      }
      }
       
       

    }

  2. CraftYourBukkit
    Offline

    CraftYourBukkit Notable Member Plugin Developer

    Joined:
    Jan 20, 2015
    Posts:
    1,022
    Plugins:
    2
    Minecraft User:
    CraftYourBukkit
    Well, what do you even want to do? (I don't see a reason for the while and the sleep)
    Also, please post this on the new forums.
    Last edited: Nov 28, 2016
    applqpak likes this.
  3. TheDeibo
    Offline

    TheDeibo Notable Member

    Joined:
    Sep 8, 2014
    Posts:
    693
    Minecraft User:
    TheDeibo
    applqpak likes this.

Share This Page

Advertisement