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

Need help Offset bool type

Discussion in 'Plugin Help' started by NZSigourney, Oct 13, 2021.

  1. NZSigourney

    NZSigourney Silverfish

    Messages:
    23
    GitHub:
    NZSigourney
    i need help :<
    TC = ... is line 36

    PHP:
    $id mt_rand(1mt_getrandmax());
                
    $name $player->getName();
                
    $tc $this->getPlugin()->tc->get(strtolower($player->getName()))["ID"];
    ErrorException: "Trying to access array offset on value of type bool" (EXCEPTION) in "plugins/ReportUI-Master/src/NZS/MS/UI/SubUI/tocaosubcommand" at line 36
     
  2. Primus

    Primus Zombie Pigman

    Messages:
    749
    "$this->getPlugin()->tc->get(strtolower($player->getName()))" returned true/false

    You can not access array offset for boolean type.

    Your code evaluates to something like this
    PHP:
    $tc true["ID"];
    Does that make sense?
     
    minijaham likes this.
  3. minijaham

    minijaham Skeleton

    Messages:
    801
    GitHub:
    minijaham
    Which makes me assume that $this->getPlugin()->tc->get(strtolower($player->getName())) is returning false because it's not set!
    I recommend using something like isset() so you can check if the key in the config exists, before executing your desired code.
     
    NTT likes this.
  4. NZSigourney

    NZSigourney Silverfish

    Messages:
    23
    GitHub:
    NZSigourney
    I try it and that error is continue
     
  5. Primus

    Primus Zombie Pigman

    Messages:
    749
    What did you try? Can you show us?
     
  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.