Advertisement
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Get player name from config and teleport

Comments in 'Plugin Development' started by Kabluinc, Aug 31, 2016.

  1. Kabluinc
    Offline

    Kabluinc New Member

    Joined:
    Mar 2, 2016
    Posts:
    29
    Minecraft User:
    Kabluinc
    Hi, sorry for posting so many threads in the last few days but after this my plugin should be done

    I have a config file which looks like this

    ___
    judge: steve
    ...

    How can i get the name from config and teleport that player to a specified xyz

    I tried
    PHP:
    $player $Config->get("judge);

    $player->teleport(new position(x, y, z));

    That however didnt work and gave a error anout something to do with string. I can get the exact error if needed

    Any help would be much appreciated
  2. Survingo
    Offline

    Survingo Active Member

    Joined:
    Dec 6, 2015
    Posts:
    221
    Because you are trying to teleport a string. Altough you forgot a ' " ' and case sensitive
    PHP:
    use pocketmine\level\Position;
    if(
    is_null($this->getServer()->getPlayer($this->getConfig()->get("judge")))) return false;//If player doesn't exists
    $this->getServer()->getPlayer($this->getConfig()->get("judge"))->teleport(new Position($x$y$z$level));//Position requires also a level object
    Kabluinc, Primus and applqpak like this.
  3. SOFe
    Offline

    SOFe Banned

    Joined:
    May 28, 2016
    Posts:
    386
    Minecraft User:
    Herobrine
    "Something to do with a string" can Mena anything.
    applqpak likes this.
  4. Kabluinc
    Offline

    Kabluinc New Member

    Joined:
    Mar 2, 2016
    Posts:
    29
    Minecraft User:
    Kabluinc
    Thanks Survingo! your code solved the issue

Share This Page

Advertisement