Solved Countdown help

Discussion in 'Help' started by Jules, Nov 25, 2018.

  1. Jules

    Jules Spider Jockey

    Messages:
    39
    GitHub:
    Julooooos
    Hello this code doesn't work.

    Spawn.php

    PHP:
    <?php

    namespace GladiatorsCore\Commandes;

    use 
    pocketmine\Player;
    use 
    pocketmine\command\Command;
    use 
    pocketmine\command\CommandSender;
    use 
    pocketmine\Server;
    use 
    GladiatorsCore\Main;
    use 
    pocketmine\plugin\Plugin;
    use 
    GladiatorsCore\Tasks\SpawnTask;

    class 
    Spawn extends Command {

        public function 
    __construct(Plugin $plugin) {
            
            
    $this->plugin $plugin;
            
    parent::__construct("spawn""Retourne au spawn !");
        }

        public function 
    execute(CommandSender $senderstring $currentAlias, array $args) {

            
    $this->plugin->getScheduler()->scheduleDelayedRepeatingTask(new SpawnTask(), 2020);

        }
    }
    SpawnTask.php

    PHP:
    <?php


    namespace GladiatorsCore\Tasks;

    use 
    pocketmine\scheduler\Task;
    use 
    pocketmine\Server;
    use 
    GladiatorsCore\Main;
    use 
    pocketmine\plugin\Plugin;
    use 
    pocketmine\Player;

    class 
    SpawnTask extends Task{

        const 
    COUNTDOWN_DURATION 5;
        private 
    $countdownValue;

        public function 
    __construct(Plugin $pluginPlayer $sender) {
            
            
    parent::__construct($plugin);
            
    $this->player $sender;
            
    $this->plugin $plugin;
            
    $this->countdownValue SpawnTask::COUNTDOWN_DURATION;
        }

        public function 
    onRun(int $currentTick){

            
    $this->sender->sendTip("§6Téléportation dans :\n§f" $this->countdownValue "");
            
    $this->countdownValue--;
            
            if(
    $this->countdownValue == 0){
                
    $this->sender->sendMessage(Main::PREFIX "§aTéléportation vers le spawn réussite !");
                
    $this->sender->teleport(Server::getInstance()->getLevelByName("monde")->getSpawnLocation());
            }
        }
    }
    And the error i get when i do the command :

    [CODE]2018-11-25 [17:42:51] [Server thread/CRITICAL]: Unhandled exception executing command 'spawn' in spawn: Too few arguments to function GladiatorsCore\Tasks\SpawnTask::__construct(), 0 passed in /home/gsp_1622/g3.hmserv.eu-19160/plugins/GladiatorsCore/src/GladiatorsCore/Commandes/Spawn.php on line 23 and exactly 2 expected
    2018-11-25 [17:42:51] [Server thread/CRITICAL]: ArgumentCountError: "Too few arguments to function GladiatorsCore\Tasks\SpawnTask::__construct(), 0 passed in /home/gsp_1622/g3.hmserv.eu-19160/plugins/GladiatorsCore/src/GladiatorsCore/Commandes/Spawn.php on line 23 and exactly 2 expected" (EXCEPTION) in "GladiatorsCore/src/GladiatorsCore/Tasks/SpawnTask" at line 16
    2018-11-25 [17:42:51] [Server thread/DEBUG]: #0 GladiatorsCore/src/GladiatorsCore/Commandes/Spawn(23): GladiatorsCore\Tasks\SpawnTask->__construct()
    2018-11-25 [17:42:51] [Server thread/DEBUG]: #1 src/pocketmine/command/SimpleCommandMap(258): GladiatorsCore\Commandes\Spawn->execute(pocketmine\Player object, string spawn, array Array())
    2018-11-25 [17:42:51] [Server thread/DEBUG]: #2 src/pocketmine/Server(1956): pocketmine\command\SimpleCommandMap->dispatch(pocketmine\Player object, string spawn)
    2018-11-25 [17:42:51] [Server thread/DEBUG]: #3 src/pocketmine/Player(2193): pocketmine\Server->dispatchCommand(pocketmine\Player object, string spawn)
    2018-11-25 [17:42:51] [Server thread/DEBUG]: #4 src/pocketmine/network/mcpe/PlayerNetworkSessionAdapter(226): pocketmine\Player->chat(string /spawn)
    2018-11-25 [17:42:51] [Server thread/DEBUG]: #5 src/pocketmine/network/mcpe/protocol/CommandRequestPacket(54): pocketmine\network\mcpe\PlayerNetworkSessionAdapter->handleCommandRequest(pocketmine\network\mcpe\protocol\CommandRequestPacket object)
    2018-11-25 [17:42:51] [Server thread/DEBUG]: #6 src/pocketmine/network/mcpe/PlayerNetworkSessionAdapter(96): pocketmine\network\mcpe\protocol\CommandRequestPacket->handle(pocketmine\network\mcpe\PlayerNetworkSessionAdapter object)
    2018-11-25 [17:42:51] [Server thread/DEBUG]: #7 src/pocketmine/network/mcpe/protocol/BatchPacket(114): pocketmine\network\mcpe\PlayerNetworkSessionAdapter->handleDataPacket(pocketmine\network\mcpe\protocol\CommandRequestPacket object)
    2018-11-25 [17:42:51] [Server thread/DEBUG]: #8 src/pocketmine/network/mcpe/PlayerNetworkSessionAdapter(96): pocketmine\network\mcpe\protocol\BatchPacket->handle(pocketmine\network\mcpe\PlayerNetworkSessionAdapter object)
    2018-11-25 [17:42:51] [Server thread/DEBUG]: #9 src/pocketmine/Player(3060): pocketmine\network\mcpe\PlayerNetworkSessionAdapter->handleDataPacket(pocketmine\network\mcpe\protocol\BatchPacket object)
    2018-11-25 [17:42:51] [Server thread/DEBUG]: #10 src/pocketmine/network/mcpe/RakLibInterface(161): pocketmine\Player->handleDataPacket(pocketmine\network\mcpe\protocol\BatchPacket object)
    2018-11-25 [17:42:51] [Server thread/DEBUG]: #11 vendor/pocketmine/raklib/src/server/ServerHandler(98): pocketmine\network\mcpe\RakLibInterface->handleEncapsulated(string 90.112.81.141 54763, raklib\protocol\EncapsulatedPacket object, integer 0)
    2018-11-25 [17:42:51] [Server thread/DEBUG]: #12 src/pocketmine/network/mcpe/RakLibInterface(102): raklib\server\ServerHandler->handlePacket()
    2018-11-25 [17:42:51] [Server thread/DEBUG]: #13 src/pocketmine/network/Network(94): pocketmine\network\mcpe\RakLibInterface->process()
    2018-11-25 [17:42:51] [Server thread/DEBUG]: #14 src/pocketmine/network/mcpe/RakLibInterface(92): pocketmine\network\Network->processInterface(pocketmine\network\mcpe\RakLibInterface object)
    2018-11-25 [17:42:51] [Server thread/DEBUG]: #15 vendor/pocketmine/snooze/src/SleeperHandler(120): pocketmine\network\mcpe\RakLibInterface->pocketmine\network\mcpe\{closure}()
    2018-11-25 [17:42:51] [Server thread/DEBUG]: #16 vendor/pocketmine/snooze/src/SleeperHandler(82): pocketmine\snooze\SleeperHandler->processNotifications()
    2018-11-25 [17:42:51] [Server thread/DEBUG]: #17 src/pocketmine/Server(2268): pocketmine\snooze\SleeperHandler->sleepUntil(double 1543164171.3397)
    2018-11-25 [17:42:51] [Server thread/DEBUG]: #18 src/pocketmine/Server(2135): pocketmine\Server->tickProcessor()
    2018-11-25 [17:42:51] [Server thread/DEBUG]: #19 src/pocketmine/Server(1701): pocketmine\Server->start()
    2018-11-25 [17:42:51] [Server thread/DEBUG]: #20 src/pocketmine/PocketMine(249): pocketmine\Server->__construct(BaseClassLoader object, pocketmine\utils\MainLogger object, string /home/gsp_1622/g3.hmserv.eu-19160/, string /home/gsp_1622/g3.hmserv.eu-19160/plugins/)
    2018-11-25 [17:42:51] [Server thread/DEBUG]: #21 /home/gsp_1622/g3.hmserv.eu-19160/PocketMine-MP.phar(1): require(string phar:///home/gsp_1622/g3.hmserv.eu-19160/PocketMine-MP.phar/src/pocketmine/PocketMine.php)[/CODE]

    How to fix it ?


     
    NeoZ04 likes this.
  2. MalakasPlayzMCPE

    MalakasPlayzMCPE Zombie Pigman

    Messages:
    591
    PHP:
            $this->plugin->getScheduler()->scheduleDelayedRepeatingTask(new SpawnTask($this$sender), 2020);
    On Spawn.php
     
    Jules and LewBr like this.
  3. wolfdale

    wolfdale Baby Zombie

    Messages:
    148
    Actually it should be
    PHP:
    $this->plugin->getScheduler()->scheduleDelayedRepeatingTask(new SpawnTask($this->plugin$sender), 2020);
     
    Jules likes this.
  4. NeoZ04

    NeoZ04 Spider

    Messages:
    11
    GitHub:
    neoz04
    SpawnTask.php
    Remove parent::__construct($plugin)
     
    Jules likes this.
  5. Jules

    Jules Spider Jockey

    Messages:
    39
    GitHub:
    Julooooos
    thank you all for your answers, it works!
     
    NeoZ04 likes this.

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.