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

Undefined variable $owner

Discussion in 'Help' started by MrSalmon, Jul 7, 2022.

  1. MrSalmon

    MrSalmon Creeper

    Messages:
    3
    GitHub:
    Salmon1279
    ошибка с getOwner, замененная с getOwner на owner (нашел это на этом же форуме), но после моих изменений стал жаловаться на "owner"
    class countdownTimer extends Task {

    public function __construct(PluginBase $owner, Player $player, int $secsTotal) {
    $this->player = $player;
    $this->secsTotal = $secsTotal;
    }

    public function onRun($currentTick){
    $this->endingtime = $this->owner->seconds + $this->secsTotal;
    $this->secondsLeft = $this->endingtime - time();
    if($this->owner->getConfig()->get("debug-message"))
    $this->player->sendTip($this->owner->translateColors("&e" . $this->secondsLeft . "&r"));
    if($this->secondsLeft <= 0){
    if($this->owner->isPlayerAuthenticated($this->player)) {
    $playerdata = $this->owner->getPlayerData($this->player->getName());
    if($this->owner->getConfig()->get("IPLogin") == true) {
    if($playerdata["lastip"] == $this->player->getAddress()) {
    //
    } else {
    $this->owner->deauthenticatePlayer($this->player);
    }
    } else {
    $this->owner->deauthenticatePlayer($this->player);
    }
    }
    if(!$this->owner->isPlayerRegistered($this->player->getName())) {
    $this->owner->createForm(0, $this->player);
    } else {
    if(!$this->owner->isPlayerAuthenticated($this->player)) {
    $this->owner->createForm(1, $this->player);
    }
    }
    $this->owner->getServer()->getScheduler()->cancelTasks($this->owner);
    }
    }
    }
     

    Attached Files:

  2. Primus

    Primus Zombie Pigman

    Messages:
    749
    That's because you need to set the $owner parameter taken from __constructor call and put it inside the class property.
     
    BlackRainbow likes this.
  3. MrSalmon

    MrSalmon Creeper

    Messages:
    3
    GitHub:
    Salmon1279
    thanks for the reply, but I have already found myself the solution to this problem(for English sorry, they I have thanks for the reply, but I have already found the solution to this problem myself(for English sorry, I am from Russia)
     
  4. Primus

    Primus Zombie Pigman

    Messages:
    749
    No problem, I'm fluent in the Russian language anyways.
     
    BlackRainbow 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.