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

PLUGIN DEV TEAM!!!

Comments in 'Plugin Development' started by Syriamanal, Nov 13, 2013.

  1. Dragonbone
    Offline

    Dragonbone New Member

    Joined:
    Nov 13, 2013
    Posts:
    50
    Dude why won`t this work?
    <?php

    /*
    __PocketMine Plugin__
    name=TP+
    description=Adds a new command that tp's everyone to your position
    version=1.0.0
    author=Dragonbone
    class=tp
    apiversion=10
    */

    class tp implements Plugin{
    private $api;
    public function __construct(ServerAPI $api, $server = false)
    {
    $this->api = $api;
    }

    public function init(){
    $this->api->console->register("tpall","Tp's all the online players to your position", array($this, "tp"));
    }

    public function tp($cmd, $args, $issuer)
    {
    if ($issuer !== 'console')
    $x = $issuer->entity->x;
    $y = $issuer->entity->y;
    $z = $issuer->entity->z;
    $level = $issuer->level;
    foreach($this->api->player->getAll() as $player){
    $player->teleport(new Position($x, $y, $z, $level));
    }
    return "You have succesfully teleported everyone!";
    else
    {
    console("Please run this command in-game.");
    }
    }

    public function __destruct(){}
    }
    ?>
    The error is at else, it says 'Syntax Error'
  2. Dragonbone
    Offline

    Dragonbone New Member

    Joined:
    Nov 13, 2013
    Posts:
    50
    Whats the error? It says syntax error at Else.
    <?php

    /*
    __PocketMine Plugin__
    name=TP+
    description=Adds a new command that tp's everyone to your position
    version=1.0.0
    author=Dragonbone
    class=tp
    apiversion=10
    */

    class tp implements Plugin{
    private $api;
    public function __construct(ServerAPI $api, $server = false)
    {
    $this->api = $api;
    }

    public function init(){
    $this->api->console->register("tpall","Tp's all the online players to your position", array($this, "tp"));
    }

    public function tp($cmd, $args, $issuer)
    {
    if ($issuer !== 'console')
    $x = $issuer->entity->x;
    $y = $issuer->entity->y;
    $z = $issuer->entity->z;
    $level = $issuer->level;
    foreach($this->api->player->getAll() as $player){
    $player->teleport(new Position($x, $y, $z, $level));
    }
    return "You have succesfully teleported everyone!";
    else
    {
    console("Please run this command in-game.");
    }
    }

    public function __destruct(){}
    }
    ?>
  3. Falk
    Offline

    Falk Staff Member Global Moderator

    Joined:
    Sep 2, 2013
    Posts:
    1,706
    Plugins:
    22
    Minecraft User:
    Falkirknh
    Well there is no { on the if
  4. ZacHack
    Offline

    ZacHack Staff Member Sectional Moderator

    Joined:
    Aug 23, 2013
    Posts:
    325
    Plugins:
    6
    Minecraft User:
    _ZacHack_
    Whenever it says syntax error it'll say in eval code line 38 or something look in that line. But @Falk is right u need a { but try reading the error before asking for help
    Falk likes this.
  5. Dragonbone
    Offline

    Dragonbone New Member

    Joined:
    Nov 13, 2013
    Posts:
    50
    THANKS!
  6. Falk
    Offline

    Falk Staff Member Global Moderator

    Joined:
    Sep 2, 2013
    Posts:
    1,706
    Plugins:
    22
    Minecraft User:
    Falkirknh
    Yes, but sometimes the errors could be somewhere else in the document and the interpreter only fails after the error. So it's misleading
  7. Dragonbone
    Offline

    Dragonbone New Member

    Joined:
    Nov 13, 2013
    Posts:
    50
    Okay, i did not realize it!
  8. ZacHack
    Offline

    ZacHack Staff Member Sectional Moderator

    Joined:
    Aug 23, 2013
    Posts:
    325
    Plugins:
    6
    Minecraft User:
    _ZacHack_
    Not with syntax errors. And it's usually right unless you have a Pmf format plugin
  9. Dragonbone
    Offline

    Dragonbone New Member

    Joined:
    Nov 13, 2013
    Posts:
    50
    Dude sorry for bothering you.
  10. ZacHack
    Offline

    ZacHack Staff Member Sectional Moderator

    Joined:
    Aug 23, 2013
    Posts:
    325
    Plugins:
    6
    Minecraft User:
    _ZacHack_
    No it's ok I chose to respond :p so I'm just helping so you can develop faster xD
  11. Dragonbone
    Offline

    Dragonbone New Member

    Joined:
    Nov 13, 2013
    Posts:
    50
    Thanks!
  12. Falk
    Offline

    Falk Staff Member Global Moderator

    Joined:
    Sep 2, 2013
    Posts:
    1,706
    Plugins:
    22
    Minecraft User:
    Falkirknh
    Of course it's right but say you get a coord wrong and then try to teleport. The error will be on teleport because that is where the error occurs, it is not were the fix is required. This can make it hard for newer people to get things fixed.
    Last edited: Nov 14, 2013
  13. ZacHack
    Offline

    ZacHack Staff Member Sectional Moderator

    Joined:
    Aug 23, 2013
    Posts:
    325
    Plugins:
    6
    Minecraft User:
    _ZacHack_
    It's still around that area xD
  14. Falk
    Offline

    Falk Staff Member Global Moderator

    Joined:
    Sep 2, 2013
    Posts:
    1,706
    Plugins:
    22
    Minecraft User:
    Falkirknh
    Good point
  15. TrilogiForce
    Offline

    TrilogiForce Ban Evader Banned

    Joined:
    Sep 7, 2013
    Posts:
    228
    Minecraft User:
    TrilogiForce
    wies its not like that the command its:
    /tp @a [Your name in-game]
  16. Puzzleo
    Offline

    Puzzleo Banned

    Joined:
    Sep 7, 2013
    Posts:
    88
    Minecraft User:
    puzzleo
    i started making it a week ago i was investigating PM api
  17. wies
    Offline

    wies Notable Member

    Joined:
    Aug 23, 2013
    Posts:
    390
    Don't say something before you're sure.
    @a is the same as @all
  18. Dragonbone
    Offline

    Dragonbone New Member

    Joined:
    Nov 13, 2013
    Posts:
    50
    Did i take any code? No. Is the code different? Yes, very different.
  19. Puzzleo
    Offline

    Puzzleo Banned

    Joined:
    Sep 7, 2013
    Posts:
    88
    Minecraft User:
    puzzleo
    i know dont worry
  20. Puzzleo
    Offline

    Puzzleo Banned

    Joined:
    Sep 7, 2013
    Posts:
    88
    Minecraft User:
    puzzleo
    u didnt by the way

Share This Page

Advertisement