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

[Solved] error get()

Discussion in 'Development' started by Harviy11, Feb 8, 2017.

  1. Harviy11

    Harviy11 Baby Zombie

    Messages:
    100
    PHP:
    $x $playercfg->get("spawn-x");
    $playercfg = new Config($this->main->getDataFolder() . "players/" $p->getName() . ".yml"Config::YAML);
    $y $playercfg->get("spawn-y");
    $z $playercfg->get("spawn-z");
    $p->teleport(new Vector3($x$y$z), "Arena");
    error:
    Code:
    [21:16:14] [Server thread/CRITICAL]: Could not execute task test\Task: Call to a member function get() on unknown
    [21:16:14] [Server thread/CRITICAL]: Error: "Call to a member function get() on unknown" (EXCEPTION) in "/test/src/test/Main" at line 335
    What is bad?
    spawn-y, spawn-x, spawn-z exist in playercfg.
     
  2. imYannic

    imYannic Baby Zombie

    Messages:
    113
    Move the line where $x is defined under the line where the config is defined. You define a variable before a variable which it uses ($playercfg) is defined.
     
  3. Harviy11

    Harviy11 Baby Zombie

    Messages:
    100
    Thank you!!!!!!!!
     
  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.