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

Config Error

Discussion in 'Facepalm' started by Jonas, Mar 4, 2017.

  1. Jonas

    Jonas Baby Zombie

    Messages:
    192
    This Code is wrong. Rcon says is a undefined variable , but i have a public Variable on this name.
    PHP:
    public $badWords = array(
        
    "spast",
        
    "depp",
        
    "noob",
        
    "noop",
        
    "arsch",
        
    "scheiße",
        
    "fuck you",
        
    "scheiß server",
        
    "arschloch",
        
    "dummkopf",
        
    "depp"
        
    );
        
        public function 
    onEnable() {
            
    $this->getLogger()->info("wurde aktiviert");
            @
    mkdir($this->getDataFolder());
        
            
    $cfg = new Config($this->getDataFolder(). "BadWords.yml"Config::YAML);
        
            if(empty(
    $cfg->get("BadWords"))) {
               
    $cfg->set("BadWords"$badWords);
               
    $cfg->save();
            }
        }
     
  2. Thunder33345

    Thunder33345 Moderator Staff Member

    Messages:
    2,137
    GitHub:
    Thunder33345
    Learn OOP and php, No like for real i am not saying this just because it is cliche thing to say
    And i am backing it up with the fact that that's now how you access a property
     
  3. jasonwynn10

    jasonwynn10 Moderator Poggit Reviewer

    Messages:
    1,489
    GitHub:
    jasonwynn10
    PUT THIS IN THE FACEPALM SECTION!
    Anyway, the reason that it's giving an error is because of the variable you are using to set the "badwords"
    PHP:
    public $badWords = array(
        
    "spast",
        
    "depp",
        
    "noob",
        
    "noop",
        
    "arsch",
        
    "scheiße",
        
    "fuck you",
        
    "scheiß server",
        
    "arschloch",
        
    "dummkopf",
        
    "depp"
        
    );
        
        public function 
    onEnable() {
            
    $this->getLogger()->info("wurde aktiviert");
            @
    mkdir($this->getDataFolder());
        
            
    $cfg = new Config($this->getDataFolder(). "BadWords.yml"Config::YAML);
        
            if(empty(
    $cfg->get("BadWords"))) {
               
    $cfg->set("BadWords"$this->badWords); // use $this->badWords instead of $badWords because it's a global variable
               
    $cfg->save();
            }
        }
     
  4. Jonas

    Jonas Baby Zombie

    Messages:
    192
    Than comes an error: Warning: yaml_edit(): Invalid UFT-8 sequence in argument in phar: emuleted/0/PocketMine/PocketMine-MB.phar/src/pocketmine/utils/Config.php on Line
    195.
     
  5. jasonwynn10

    jasonwynn10 Moderator Poggit Reviewer

    Messages:
    1,489
    GitHub:
    jasonwynn10
    That's beause of the "ß" character
     
  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.