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

[ERROR] help with getid()

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

  1. jerlegoman
    Offline

    jerlegoman Active Member

    Joined:
    Dec 10, 2013
    Posts:
    120
    Minecraft User:
    jeremy647
    ok thanks
  2. LDX
    Offline

    LDX Notable Member Plugin Developer

    Joined:
    Oct 2, 2013
    Posts:
    1,397
    Plugins:
    14
    Is player.action an event??
  3. swagboy47
    Offline

    swagboy47 Active Member

    Joined:
    Jun 10, 2014
    Posts:
    445
    Minecraft User:
    swagking
    yep
  4. jerlegoman
    Offline

    jerlegoman Active Member

    Joined:
    Dec 10, 2013
    Posts:
    120
    Minecraft User:
    jeremy647
    I never knew player.action was a event until I saw TPcompass's code
  5. LDX
    Offline

    LDX Notable Member Plugin Developer

    Joined:
    Oct 2, 2013
    Posts:
    1,397
    Plugins:
    14
    Boom. Thanks for the plugin idea. (I'm not copying yours, but that gave me another idea.)
    jerlegoman likes this.
  6. jerlegoman
    Offline

    jerlegoman Active Member

    Joined:
    Dec 10, 2013
    Posts:
    120
    Minecraft User:
    jeremy647
    Ok your welcome always happy to help!:)
  7. jerlegoman
    Offline

    jerlegoman Active Member

    Joined:
    Dec 10, 2013
    Posts:
    120
    Minecraft User:
    jeremy647
    one issue with the code now there is an error with line 27 for some reason here is the code now:
    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.action", array($this"eventHandle"), 50);
    }
    public function 
    eventHandle($data$event) {
    switch (
    $event) {
    case 
    "player.action":
    $player $data["player"];
    $item $player->getSlot($player->slot);
    if(
    $data["item"]->getID() == 345) {
    $data->sendChat("** Have Fun and BE CARE FULL!");
    }
    }
    public function 
    __destruct() {
    }
    ?> 
    [NOTE]: line 27 is:
    PHP:
    public function __destruct() { 
  8. swagboy47
    Offline

    swagboy47 Active Member

    Joined:
    Jun 10, 2014
    Posts:
    445
    Minecraft User:
    swagking
    you are missing an } at the very end
    jerlegoman likes this.
  9. jerlegoman
    Offline

    jerlegoman Active Member

    Joined:
    Dec 10, 2013
    Posts:
    120
    Minecraft User:
    jeremy647
    oh whoops didn't noticeo_O
  10. swagboy47
    Offline

    swagboy47 Active Member

    Joined:
    Jun 10, 2014
    Posts:
    445
    Minecraft User:
    swagking
    if($data["item"]->getid() == 345) {
    should be
    if($item->getID() == 345) {
    jerlegoman likes this.
  11. jerlegoman
    Offline

    jerlegoman Active Member

    Joined:
    Dec 10, 2013
    Posts:
    120
    Minecraft User:
    jeremy647
    I got an error when doing it like this still
    PHP:
    public function __destruct() { }
  12. swagboy47
    Offline

    swagboy47 Active Member

    Joined:
    Jun 10, 2014
    Posts:
    445
    Minecraft User:
    swagking
    nope
    public function __destruct() { }
    }
    to end the
    class spaplus implements Plugin {
    jerlegoman likes this.
  13. swagboy47
    Offline

    swagboy47 Active Member

    Joined:
    Jun 10, 2014
    Posts:
    445
    Minecraft User:
    swagking
    use github for coding it helped me a lot to catch those mistakes
    jerlegoman likes this.
  14. jerlegoman
    Offline

    jerlegoman Active Member

    Joined:
    Dec 10, 2013
    Posts:
    120
    Minecraft User:
    jeremy647
    I'm still having an error on line 27 even with the } at the end
  15. swagboy47
    Offline

    swagboy47 Active Member

    Joined:
    Jun 10, 2014
    Posts:
    445
    Minecraft User:
    swagking
  16. swagboy47
    Offline

    swagboy47 Active Member

    Joined:
    Jun 10, 2014
    Posts:
    445
    Minecraft User:
    swagking
    sorry not that one :p
  17. swagboy47
    Offline

    swagboy47 Active Member

    Joined:
    Jun 10, 2014
    Posts:
    445
    Minecraft User:
    swagking
  18. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    Why need it?
    Use notepad++
  19. jerlegoman
    Offline

    jerlegoman Active Member

    Joined:
    Dec 10, 2013
    Posts:
    120
    Minecraft User:
    jeremy647
    I am using notepad++
  20. swagboy47
    Offline

    swagboy47 Active Member

    Joined:
    Jun 10, 2014
    Posts:
    445
    Minecraft User:
    swagking
    i use github because my parents doesn't let me download note++ :p

Share This Page

Advertisement