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

Problem with lagg

Comments in 'Plugin Development' started by Ritch, Jun 9, 2016.

  1. Ritch
    Offline

    Ritch Active Member

    Joined:
    Oct 4, 2015
    Posts:
    184
    Minecraft User:
    anonymous
    2016-03-15 [14:54:03] [Server thread/CRITICAL]: Could not execute task Game\OpenArena: Undefined property: Game\Main::$timer
    2016-03-15 [14:54:03] [Server thread/NOTICE]: UndefinedPropertyException: "Undefined property: Game\Main::$timer" (E_NOTICE)

    I guys i have a problem of my Task lagg ?

    PHP:
    //code of my Task part 1 /2

    <?php

    namespace Game;

    use 
    pocketmine\scheduler\PluginTask;
    use 
    pocketmine\utils\TextFormat;
    use 
    pocketmine\tile\Tile;
    use 
    pocketmine\tile\Sign;
    use 
    pocketmine\math\Vector3;
    use 
    pocketmine\level\Level;
    use 
    pocketmine\level\Position;

    class 
    OpenArena extends PluginTask {

        public function 
    __construct(Main $plugin) {
            
    $this->plugin $plugin;
             
    parent::__construct($plugin);
         }

         public function 
    onRun($refreshTick) {
            
    $this->plugin->OpenArena();

         }
    }

    //Part 2 Problem..

    $this->getServer()->getScheduler()->scheduleRepeatingTask(new OpenArena($this), 1);

        public function 
    OpenArena(){
          
    $counter count($this->getServer()->getOnlinePlayers());
            foreach(
    $this->getServer()->getOnlinePlayers() as $player) {
                
    $lvl $player->getLevel()->getName();
                if(
    $lvl === "test"){
                    if(
    $this->gameStarted === false){
                        
    $this->getServer()->loadLevel("test");
                    
    $players $this->getServer()->getLevelByName("test")->getPlayers();
                    
    $player->sendPopup("§e[§bGame§e]§r\n §6Waiting for players... §f".count($players)."/8§r");
                    }
                    if(
    $this->gameStarted === true){
                             
    $this->getServer()->loadLevel("test");
                        
    $players $this->getServer()->getLevelByName("test")->getPlayers();
                         
    $player->sendPopup("§e[§bGame§e]\n §f» Finish in §e[§c".$this->min.":00§e] §fminute(s)\n §7players alive: §6".count($players)." §7coord: §6{$player->getFloorX()}{$player->getFloorY()}{$player->getFloorZ()}§r");
                         return;
                         }
                         }   
                         }
                      }        
                  }
  2. Gamecrafter
    Offline

    Gamecrafter

    Joined:
    Nov 20, 2014
    Posts:
    978
    Plugins:
    9
    Please learn how to read errors. Your problem is not caused by lag, it is caused by you trying to access an undefined property, which in this case, is Game\Main::$timer. Showing your full code would help. And also, next time, please indent your code a bit better. :)
    Ritch and CraftYourBukkit like this.
  3. Primus
    Offline

    Primus Notable Member

    Joined:
    Apr 7, 2015
    Posts:
    1,470
    Minecraft User:
    PrimusLV
    You haven't assigned any value to variable Main::$timer

    You have to initialize the variable before scheduling the task.
    PHP:
    $this->timer 0;
    It would be helpful if you post the whole error, I'm sure it must point to a specific line.

    And the code you showed us, nowhere access that property anyway, why did you post this irrelevant code?
  4. SOFe
    Offline

    SOFe Banned

    Joined:
    May 28, 2016
    Posts:
    386
    Minecraft User:
    Herobrine
    Your error has no relevance with lag.
    Legoboy0215 likes this.

Share This Page

Advertisement