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

Teleporting a player to given x,y,z,level

Comments in 'Plugin Development' started by EschieEsh, Feb 6, 2016.

  1. EschieEsh
    Offline

    EschieEsh Active Member

    Joined:
    Jun 28, 2014
    Posts:
    69
    Minecraft User:
    Escherion
    I use SQLite3 ->

    ....
    $stmt->bindValue(":x", $sender->getX());
    $stmt->bindValue(":y", $sender->getY());
    $stmt->bindValue(":z", $sender->getZ());
    $stmt->bindValue(":world", $sender->getPlayer()->getLevel());
    $result = $stmt->execute();

    Later in the code ->
    ....
    $sender->getPlayer()->teleport(new Position($array['x'], $array['y'], $array['z'], $array['world']));

    The player won't teleport to the given position. Instead, I get this ->
    Object of class pocketmine\level\Level could not be converted to string. Help?
  2. Tim // robske Büba
    Offline

    Tim // robske Büba Notable Member

    Joined:
    Feb 26, 2014
    Posts:
    606
    Minecraft User:
    robske_110
    You need to have the level OBJECT
    PHP:
    $worldAsObject $this->getServer()->getLevelByName($array['world']);
    and then use it
    PHP:
    $sender->getPlayer()->teleport(new Position($array['x'], $array['y'], $array['z'], $worldAsObject));
  3. EschieEsh
    Offline

    EschieEsh Active Member

    Joined:
    Jun 28, 2014
    Posts:
    69
    Minecraft User:
    Escherion
    wow, thanks! That was quick
  4. EschieEsh
    Offline

    EschieEsh Active Member

    Joined:
    Jun 28, 2014
    Posts:
    69
    Minecraft User:
    Escherion
    It is very hard to test a plugin now :/. MCPE crashes everytime I connect to my MCPE server.
  5. EschieEsh
    Offline

    EschieEsh Active Member

    Joined:
    Jun 28, 2014
    Posts:
    69
    Minecraft User:
    Escherion
    It won't even launch now :/
  6. EschieEsh
    Offline

    EschieEsh Active Member

    Joined:
    Jun 28, 2014
    Posts:
    69
    Minecraft User:
    Escherion
    I am sorry for any confusion guys. I mean MCPE 0.13.2 won't launch, not the plugin. And I can't test the plugin because of it
  7. Tim // robske Büba
    Offline

    Tim // robske Büba Notable Member

    Joined:
    Feb 26, 2014
    Posts:
    606
    Minecraft User:
    robske_110
    Try to reinstall MCPE
  8. EschieEsh
    Offline

    EschieEsh Active Member

    Joined:
    Jun 28, 2014
    Posts:
    69
    Minecraft User:
    Escherion
    Done. The plugin still doesn't work. Error on this line -

    $stmt->bindValue(":world", $sender->getPlayer()->getLevel());


    Object of class pocketmine\level\Level could not be converted to string. Still appears
  9. CraftYourBukkit
    Offline

    CraftYourBukkit Notable Member Plugin Developer

    Joined:
    Jan 20, 2015
    Posts:
    1,022
    Plugins:
    2
    Minecraft User:
    CraftYourBukkit
    Try to understand error codes.
    PHP:
    $stmt->bindValue(":world"$sender->getLevel()->getName());
    Last edited: Feb 6, 2016
    PEMapModder and PocketKiller like this.
  10. EschieEsh
    Offline

    EschieEsh Active Member

    Joined:
    Jun 28, 2014
    Posts:
    69
    Minecraft User:
    Escherion
    Wow I am such an idiot. Of course!. thanks
  11. jojoe77777
    Offline

    jojoe77777 Notable Member Plugin Developer

    Joined:
    May 28, 2015
    Posts:
    653
    Plugins:
    1
    Minecraft User:
    jojoe77777
    I got a notification from this message saying you quoted my post...?! I didn't even post in this thread.
  12. Hotshot_9930
    Offline

    Hotshot_9930 Notable Member Plugin Developer

    Joined:
    May 26, 2014
    Posts:
    665
    Plugins:
    2
    Minecraft User:
    HotshotHD
    $sender->getPlayer() doesn't make any sense.
    How did you define $sender anyways?
  13. CraftYourBukkit
    Offline

    CraftYourBukkit Notable Member Plugin Developer

    Joined:
    Jan 20, 2015
    Posts:
    1,022
    Plugins:
    2
    Minecraft User:
    CraftYourBukkit
    PEMapModder and PocketKiller like this.
  14. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder

Share This Page

Advertisement