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

Error with my code

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

  1. jerlegoman
    Offline

    jerlegoman Active Member

    Joined:
    Dec 10, 2013
    Posts:
    120
    Minecraft User:
    jeremy647
    Hi my name is jerlegoman and I am developing an code but there is an error but I don't see anything wrong with
    here is my code:
    PHP:
    <?php
    /*
    __PocketMine Plugin__
    name=TOspawn
    version=1.0
    apiversion=12
    author=Jerlegoman
    class=Magic
    */
    class Magic implements Plugin {
    private 
    $api;
    public function 
    __construct(ServerAPI $api,$server false) {
    $this->api $api;
    }
    public function 
    init() {
    $this->api->addHandler("player.action", array($this"eventHandle"), 50);
    }
    public function 
    eventHandle($data$event) {
    switch (
    $event) {
    case 
    "player.action":
    $player $data["player"];
    $item $player->getSlot($player->slot);
    if(
    $item->getid()==344){
    $player->entity->dropItem("264")
    }
    }
    }
    public function 
    __destruct() {}
    }
    the error is on line 25

    here is the error in console:
    Parse error: syntax error, unexpected '}' in C:\Users\Jeremy Haft\Desktop\PocketMine-MP use only\plugins\DP.php on line 25
    Minetox likes this.
  2. Falk
    Offline

    Falk Staff Member Global Moderator

    Joined:
    Sep 2, 2013
    Posts:
    1,707
    Plugins:
    22
    Minecraft User:
    Falkirknh
    You are missing a semicolon.
  3. Minetox
    Offline

    Minetox New Member

    Joined:
    Jun 23, 2014
    Posts:
    31
    Minecraft User:
    Minetox
    I found your Problem! You forgot a Semicolon ";" on line 24

    PHP:
    <?php
    /*
    __PocketMine Plugin__
    name=TOspawn
    version=1.0
    apiversion=12
    author=Jerlegoman
    class=Magic
    */
    class Magic implements Plugin {
    private 
    $api;
    public function 
    __construct(ServerAPI $api,$server false) {
    $this->api $api;
    }
    public function 
    init() {
    $this->api->addHandler("player.action", array($this"eventHandle"), 50);
    }
    public function 
    eventHandle($data$event) {
    switch (
    $event) {
    case 
    "player.action":
    $player $data["player"];
    $item $player->getSlot($player->slot);
    if(
    $item->getid()==344){
    $player->entity->dropItem("264"); //You had before no semicolon
    }
    }
    }
    public function 
    __destruct() {}
    }
  4. jerlegoman
    Offline

    jerlegoman Active Member

    Joined:
    Dec 10, 2013
    Posts:
    120
    Minecraft User:
    jeremy647
    oh thanks!
  5. jerlegoman
    Offline

    jerlegoman Active Member

    Joined:
    Dec 10, 2013
    Posts:
    120
    Minecraft User:
    jeremy647
    now if you wanted to add a config to the dropitem would you do

    $player->entity->dropItem(".$this->config->get("itemID".");
  6. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,306
    Plugins:
    11
    Minecraft User:
    PEMapModder
    You don't need to put the quotes for numbers.

Share This Page

Advertisement