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

Why not working $this->?

Discussion in 'Development' started by Hoyee, Jun 9, 2020.

  1. Hoyee

    Hoyee Baby Zombie

    Messages:
    126
    Code:
    class UP extends Task{
    
      public $Sword;
      public $Clock;
    
      public function __construct(Sword $Sword){
    
        $this->Sword = $Sword;
    
        $this->Clock = 200;
    
      }
    
      public function onRun(int $currentTick){
    
        $this->Sword->Clock();
    
      }
    }
    Code:
    public function Clock(){
    
            $this->getServer()->broadcastTip("{$this->Clock}");     //<---- here is line 63
    
            $this->Clock--;
    
          }
    it says "Undefined property: sword\Sword::$Clock" (EXCEPTION)

    error at line 63.
     
  2. dadodasyra

    dadodasyra Witch

    Messages:
    68
    GitHub:
    dadodasyra
    $this->Sword does not contain the Clock variable
     
  3. Hoyee

    Hoyee Baby Zombie

    Messages:
    126
    then What should I do? Actually I want to make a timer
     
  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.