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

help with making a plugin

Comments in 'Plugin Development' started by jerlegoman, Mar 2, 2014.

  1. jerlegoman
    Offline

    jerlegoman Active Member

    Joined:
    Dec 10, 2013
    Posts:
    120
    Minecraft User:
    jeremy647
    hi my name is jermy647. im trying to make a plugin that allows me to make a custom message when a player quits its bradcasts it and I also added a setting in the code to include the $issuer but I had an error when testing it so can anyone please help me. Thanks I will attach the php file to this thread.

    Attached Files:

    • quit.php
      File size:
      693 bytes
      Views:
      17
  2. Topic
    Offline

    Topic New Member Plugin Developer

    Joined:
    Aug 29, 2013
    Posts:
    47
    Plugins:
    3
    Minecraft User:
    topic
    You can't use issuer in event, try this:
    PHP:
    public function eventHandler($data$event){
            switch(
    $event){
                case 
    "player.quit":
                
    $username $data->username;
                
    $this->api->chat->broadcast("$username left the game");
       }
  3. jerlegoman
    Offline

    jerlegoman Active Member

    Joined:
    Dec 10, 2013
    Posts:
    120
    Minecraft User:
    jeremy647
    ok thanks
  4. jerlegoman
    Offline

    jerlegoman Active Member

    Joined:
    Dec 10, 2013
    Posts:
    120
    Minecraft User:
    jeremy647
    when I tested out your new code I got this error:

    Parse error: syntax error, unexpected 'public' (T_PUBLIC) in C:\Users\Jeremy Haft\Desktop\PocketMine-MP use only\plugins\quit.php on line 35
    04:47:08 [INFO] Unloading level "guest1"
  5. Topic
    Offline

    Topic New Member Plugin Developer

    Joined:
    Aug 29, 2013
    Posts:
    47
    Plugins:
    3
    Minecraft User:
    topic
    I'm sorry, you need one } try this
    PHP:
    public function eventHandler($data$event){
            switch(
    $event){
                case 
    "player.quit":
                
    $username $data->username;
                
    $this->api->chat->broadcast("$username left the game");
       }
    }
  6. jerlegoman
    Offline

    jerlegoman Active Member

    Joined:
    Dec 10, 2013
    Posts:
    120
    Minecraft User:
    jeremy647
    after that part of the code does that replace
    public function __destruct(){
  7. Men'o'Gang!
    Offline

    Men'o'Gang! Ban Evader Banned

    Joined:
    Mar 3, 2014
    Posts:
    18
    no never remove public function __destruct(){} or it will crash only if you have public function __create(){} i think at the beggining of the plugin
  8. Darunia18
    Offline

    Darunia18 Staff Member Sectional Moderator

    Joined:
    Aug 23, 2013
    Posts:
    755
    Plugins:
    2
    Minecraft User:
    Darunia18
    After the event, put the __destruct thing. By the way, for the custom message, I think you have to do $this->api->chat->broadcast($username." left the game");
  9. Topic
    Offline

    Topic New Member Plugin Developer

    Joined:
    Aug 29, 2013
    Posts:
    47
    Plugins:
    3
    Minecraft User:
    topic
    Not necessarily, PocketMine can read this too ($this->api->chat->broadcast("$username massege"))
  10. Darunia18
    Offline

    Darunia18 Staff Member Sectional Moderator

    Joined:
    Aug 23, 2013
    Posts:
    755
    Plugins:
    2
    Minecraft User:
    Darunia18
    Really? That's pretty cool! :D
    Topic likes this.
  11. Topic
    Offline

    Topic New Member Plugin Developer

    Joined:
    Aug 29, 2013
    Posts:
    47
    Plugins:
    3
    Minecraft User:
    topic
    Yes, but I have habit and use $username."message" :D
    Darunia18 likes this.

Share This Page

Advertisement