1. The forums will be archived and moved to a read only mode in about 2 weeks (mid march).

crush server plugin

Discussion in 'Plugin Help' started by WylSmart, Jan 14, 2020.

  1. WylSmart

    WylSmart Slime

    Messages:
    93
    help fix the problem the server sometimes crashes
    https://github.com/SugarPocket/TopMoney/blob/master/src/topmoney/SendTask.php
    Code:
    2020-01-14 [16:02:29] [Server thread/CRITICAL]: Error: "Call to a member function addParticle() on null" (EXCEPTION) in "plugins/TopMoney-master/src/topmoney/SendTask" at line 66
    PHP:
       public function onRun(int $currentTick){
            
    $player $this->player;
            
    $x $this->plugin->getConfig()->get("x");
            
    $y $this->plugin->getConfig()->get("y");
            
    $z $this->plugin->getConfig()->get("z");
         
            
    $unit $this->plugin->getConfig()->get("unit");
         
            
    $money $this->plugin->getServer()->getPluginManager()->getPlugin("EconomyAPI");
            
    $money_top $money->getAllMoney();
            
    $message "";
            
    $message1 "";
            
    $topmoney "     В§eВ§f== :: В§cMCraft В§f:: == > В§6В§lРўРћРџ-БОГАЧЕЙ    ";
            
    $topmoney1 "     В§6В§f== :: В§cMCraft В§f:: == > В§6В§lРўРћРџ-БОГАЧЕЙ    ";
            if(
    count($money_top) > 0){
                
    arsort($money_top);
                
    $i 1;
                foreach(
    $money_top as $name => $money){
                    
    $message .= " В§b #".$i.". В§d".$name."    В§f".$money." В§a$unit\n";
                    
    $message1 .= " В§b #".$i.". В§d".$name."    В§9".$money." В§a$unit\n";
                    if(
    $i >= 10){
                        break;
                        }
                        ++
    $i;
                    }
                }
                
    $p = new FloatingTextParticle(new Vector3($x$y$z), $message$topmoney);
            
    //    $p1 = new FloatingTextParticle(new Vector3($x, $y, $z), $message1, $topmoney1);
                
    $player->getLevel()->addParticle($p);
            
    //    $player->getLevel()->addParticle($p1);
        
    }
    }
     
  2. HeyDeniis_

    HeyDeniis_ Baby Zombie

    Messages:
    137
    $player->getLevel() is Not defined or value returned is null!
     
  3. hexmor

    hexmor Baby Zombie

    Messages:
    110
    GitHub:
    h3xmor
    i recommend to use slapper nametag . its better . the problem is you did not set position . if you want to make a leader board this code is crash cuz will add a floating text for every online player ! . but you could fix the error whit
    if(!is_null($player)){
    $player->getLevel()->addParticle($p); //if player is online
    }
    but this will not work as a leaderboard .

    sry for bad english
     
  4. wolfdale

    wolfdale Zombie Pigman

    Messages:
    535
    GitHub:
    diamond-gold
    Since the task is scheduled 200 ticks or 10 seconds after the player joined, the player probably quit the server before the task is run
    Simple fix is to check if the player is still online
    PHP:
    public function onRun(int $currentTick){
    if(!
    $this->player->isOnline()) return;
    $player $this->player;
    $x $this->plugin->getConfig()->get("x");
    $y $this->plugin->getConfig()->get("y");
    $z $this->plugin->getConfig()->get("z");
    ...
     
    HimbeersaftLP likes this.
  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.