Need help Offset bool type

Discussion in 'Plugin Help' started by NZSigourney, Oct 13, 2021 at 3:12 PM.

  1. NZSigourney

    NZSigourney Silverfish

    Messages:
    16
    GitHub:
    BlackPMFury
    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:
    697
    "$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 Zombie Pigman

    Messages:
    737
    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:
    16
    GitHub:
    BlackPMFury
    I try it and that error is continue
     
  5. Primus

    Primus Zombie Pigman

    Messages:
    697
    What did you try? Can you show us?
     

Share This Page

  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.