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

help deveploping my first plugin

Comments in 'Plugin Development' started by jerlegoman, Jun 8, 2014.

  1. jerlegoman
    Offline

    jerlegoman Active Member

    Joined:
    Dec 10, 2013
    Posts:
    120
    Minecraft User:
    jeremy647
    Hi my name is Jerlegoman:) I am developing my first plugin there is an error on line 19 pls help
    PHP:
    <?php
    /*
    __PocketMine Plugin__
    name=TOspawn
    version=1.0
    apiversion=12
    author=Jerlegoman
    class=spaplus
    */
    class spaplus implements Plugin {
    private 
    $api;
    public function 
    __construct(ServerAPI $api,$server false) {
    $this->api  $api;
    }
    public function 
    init() {
    $this->api->addHandler("player.block.touch",array($this,"touch"));
    }
    public function 
    touch($data) {
    if(
    $this->enabled == true && $data["item"]->getID() == 345) {
    $this->api->console->run("spawn");
    return 
    false;
    }
    }
    public function 
    __destruct() { }
    }
    ?>
    Hanxel10 and Dinokiller like this.
  2. FunneyShip
    Offline

    FunneyShip Active Member

    Joined:
    Jun 7, 2014
    Posts:
    36
    Minecraft User:
    FunneyMan
    What is it?
  3. jerlegoman
    Offline

    jerlegoman Active Member

    Joined:
    Dec 10, 2013
    Posts:
    120
    Minecraft User:
    jeremy647
    it teleports you to spawn when you click on your compass
  4. FunneyShip
    Offline

    FunneyShip Active Member

    Joined:
    Jun 7, 2014
    Posts:
    36
    Minecraft User:
    FunneyMan
    I mean the error
  5. FunneyShip
    Offline

    FunneyShip Active Member

    Joined:
    Jun 7, 2014
    Posts:
    36
    Minecraft User:
    FunneyMan
    You mean when you have a compass in your haned?
  6. jerlegoman
    Offline

    jerlegoman Active Member

    Joined:
    Dec 10, 2013
    Posts:
    120
    Minecraft User:
    jeremy647
    oh im sorry the code is:
    PHP:
    <?php
    /*
    __PocketMine Plugin__
    name=TOspawn
    version=1.0
    apiversion=12
    author=Jerlegoman
    class=spaplus
    */
    class spaplus implements Plugin {
    private 
    $api;
    public function 
    __construct(ServerAPI $api,$server false) {
    $this->api  $api;
    }
    public function 
    init() {
    $this->api->addHandler("player.block.touch",array($this,"touch"));
    }
    public function 
    touch($data) {
    $data["item"]->getID() == 345) {
    $this->api->console->run("spawn");
    return 
    false;
    }
    }
    public function 
    __destruct() { }
    }
    ?>
  7. FunneyShip
    Offline

    FunneyShip Active Member

    Joined:
    Jun 7, 2014
    Posts:
    36
    Minecraft User:
    FunneyMan
    So you want that if you have camposs in your hand it well teleport you to spawn.right?
    jerlegoman likes this.
  8. jerlegoman
    Offline

    jerlegoman Active Member

    Joined:
    Dec 10, 2013
    Posts:
    120
    Minecraft User:
    jeremy647
    the error is:
    Parse error: syntax error, unexpected ')' in C:\Users\Jeremy Haft\Desktop\PocketMine-MP use only\plugins\TPspawn.php on line 19
  9. jerlegoman
    Offline

    jerlegoman Active Member

    Joined:
    Dec 10, 2013
    Posts:
    120
    Minecraft User:
    jeremy647
    yes
  10. FunneyShip
    Offline

    FunneyShip Active Member

    Joined:
    Jun 7, 2014
    Posts:
    36
    Minecraft User:
    FunneyMan
    Sorry to say that but your event is wrong it should be player.equipment.change . And i dont think you need return false.
  11. jerlegoman
    Offline

    jerlegoman Active Member

    Joined:
    Dec 10, 2013
    Posts:
    120
    Minecraft User:
    jeremy647
    ok ill try that
  12. FunneyShip
    Offline

    FunneyShip Active Member

    Joined:
    Jun 7, 2014
    Posts:
    36
    Minecraft User:
    FunneyMan
    Yea and line 19 should be

    If($data["item"]->getID() == 345) {
  13. FunneyShip
    Offline

    FunneyShip Active Member

    Joined:
    Jun 7, 2014
    Posts:
    36
    Minecraft User:
    FunneyMan
    You cant put a function with out switch/if statment i recomend that you go learn php form codeacademy
  14. jerlegoman
    Offline

    jerlegoman Active Member

    Joined:
    Dec 10, 2013
    Posts:
    120
    Minecraft User:
    jeremy647
    ok this time the error was online 20
    Parse error: syntax error, unexpected ')' in C:\Users\Jeremy Haft\Desktop\PocketMine-MP use only\plugins\TPspawn.php on line 20
    PHP:
    <?php
    /*
    __PocketMine Plugin__
    name=TOspawn
    version=1.0
    apiversion=12
    author=Jerlegoman
    class=spaplus
    */
    class spaplus implements Plugin {
    private 
    $api;
    public function 
    __construct(ServerAPI $api,$server false) {
    $this->api  $api;
    }
    public function 
    init() {
    $this->api->addHandler("player.equipment.change
    "
    ,array($this,"touch"));
    }
    public function 
    touch($data) {
    $data["item"]->getID() == 345) {
    $this->api->console->run("spawn");
    }
    }
    public function 
    __destruct() { }
    }
    ?>
  15. FunneyShip
    Offline

    FunneyShip Active Member

    Joined:
    Jun 7, 2014
    Posts:
    36
    Minecraft User:
    FunneyMan
  16. jerlegoman
    Offline

    jerlegoman Active Member

    Joined:
    Dec 10, 2013
    Posts:
    120
    Minecraft User:
    jeremy647
    there is no more errors but I want to use player.block.touch because I want the player t hold down on the screen then it tps them to the location for an example if you use LDX tpcommpass it tps them to the location when they hold on to the screen with a compass they tp there. but when I tried it it wont go to spawn
  17. FunneyShip
    Offline

    FunneyShip Active Member

    Joined:
    Jun 7, 2014
    Posts:
    36
    Minecraft User:
    FunneyMan
    First tpcamposs is not by ldx secoend player.touch.block well work if you tap a block with your compass player.equipment.change is when you switch from an item to the compass then it well teleport you home tpcompass by blinksun uses player.action which i dont understand it yet it uses a whole different complex system
  18. FunneyShip
    Offline

    FunneyShip Active Member

    Joined:
    Jun 7, 2014
    Posts:
    36
    Minecraft User:
    FunneyMan
    So whatever event you want then choose it
  19. Mclover152
    Offline

    Mclover152 Active Member

    Joined:
    Apr 26, 2014
    Posts:
    64
    Minecraft User:
    mclover152
    The problem is, your telling the console to run /spawn. Not a player. You need to make the functions output where it runs a sudo for the player to spawn. I recommend the output should be of the function tppos. You need to tell the console to telaport the player to spawn. When you did that output, you basically told the console to teleport to spawn.
  20. FunneyShip
    Offline

    FunneyShip Active Member

    Joined:
    Jun 7, 2014
    Posts:
    36
    Minecraft User:
    FunneyMan
    Yo
    You are right but this not what makes the errors is that he didnt put a if/switch statment but totalley forgot about the sudo
    jerlegoman likes this.

Share This Page

Advertisement