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

Countdown

Comments in 'Plugin Development' started by mclab, Jan 19, 2015.

  1. mclab
    Offline

    mclab Active Member

    Joined:
    Dec 24, 2014
    Posts:
    49
    Minecraft User:
    Dragonflex
    PHP:
    <?php
    namespace Warper;

    use 
    pocketmine\event\Listener;

    use 
    pocketmine\plugin\PluginBase;

    use 
    pocketmine\utils\TextFormat;
    use 
    pocketmine\utils\Config;

    use 
    pocketmine\command\Command;
    use 
    pocketmine\command\CommandSender;

    use 
    pocketmine\event\player\PlayerCommandPreprocessEvent;

    use 
    pocketmine\Server;
    use 
    pocketmine\Player;


    class 
    Main extends PluginBase implements Listener{

        public 
    $temp = array();

        public function 
    onEnable(){

            
    $this->getServer()->getPluginManager()->registerEvents($this$this);
            
    $this->getLogger()->info(TextFormat::YELLOW "Warper loaded");

        }


        public function 
    onCommand(CommandSender $senderCommand $command$label, array $args) {

            switch(
    $command->getName()) {
                
              
    case 
    "lobby":
               
            
    $secs 5;
            
    $czas time ();
            
    $time $czas $secs;
            
    $lol $time $czas;
            while(
    $czas $time) {
            
    $sender->sendMessage("• $lol seconds ");
        }
                   
                    break;
            
            }
        }


    }
    can someone help me with countdown plugin?
    Last edited: Jan 19, 2015
  2. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    Simple inspection:
    • $czas is an integer but used as an array
    • $time1 to $time4 are never used
    • $time in the foreach() block is never used
    • Undefined $this->cfg; you just don't need to do it.
  3. mclab
    Offline

    mclab Active Member

    Joined:
    Dec 24, 2014
    Posts:
    49
    Minecraft User:
    Dragonflex
    Edited first post :)

    Can you help me? I dont know how to do this xD
  4. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    Learn PHP... Do you know what you're doing with $lol? And do you know what a while loop is?
  5. mclab
    Offline

    mclab Active Member

    Joined:
    Dec 24, 2014
    Posts:
    49
    Minecraft User:
    Dragonflex
    I know, but i dont know how to make timer... huh....
  6. mclab
    Offline

    mclab Active Member

    Joined:
    Dec 24, 2014
    Posts:
    49
    Minecraft User:
    Dragonflex
    Urgh.... Thanks for help -_-

    I done it!

    PHP:
    <?php

    namespace testplugin;

    use 
    pocketmine\plugin\PluginBase;
    use 
    pocketmine\event\Listener;
    use 
    pocketmine\event\server\ServerCommandEvent;
    use 
    pocketmine\Server;
    use 
    pocketmine\Player;
    use 
    pocketmine\utils\TextFormat;
    use 
    pocketmine\nbt\tag\Int;
    use 
    pocketmine\scheduler\CallbackTask;
    use 
    pocketmine\command\CommandSender;
    use 
    pocketmine\command\Command;

    class 
    GameModeKick extends PluginBase implements Listener {
        public function 
    onEnable() {
            
    $this->getServer ()->getPluginManager ()->registerEvents $this$this );
        }
        public function 
    onCommand(CommandSender $senderCommand $command$label, Array $args) {
        switch(
    $command->getName()) {
        case 
    "lobby":
                
    $target $sender;
                
    $this->teleportation $target );
                break;
                }
        }
        public function 
    teleportation(Player $player) {
       
            
    $player->sendMessage "Teleportation in few seconds..." );
       
            
    $this->getServer ()->getScheduler ()->scheduleDelayedTask ( new CallbackTask ( [
                    
    $this,
                    
    "Tele"
            
    ], [
                    
    $player
            
    ] ), 100 );

            return 
    true;
        }
        public function 
    Tele(Player $player) {
    //Some code will be added :)
            
    $player->sendMessage "Teleportated..." );
        }
    }

    ?>
  7. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    Plugins are not allowed to use CallbackTask's. Write your own task class instead.

Share This Page

Advertisement