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

HELP: Join Notification plugin

Comments in 'Plugin Development' started by HyperGamers, Aug 31, 2014.

  1. HyperGamers
    Offline

    HyperGamers New Member

    Joined:
    Aug 16, 2014
    Posts:
    16
    Minecraft User:
    HyperGamers
    PHP:
    <?php

    namespace JoinNotification;

    use 
    pocketmine\plugin\PluginBase;
    use 
    pocketmine\event\player\PlayerJoinEvent;
    use 
    pocketmine\Player;
    use 
    pocketmine\Server;
    use 
    pocketmine\event\Listener;

    class 
    Main extends PluginBase implements Listener{                                       
        public function 
    onEnable() {

            
    $this->getServer()->getPluginManager()->registerEvents($this$this);

            
    $this->getLogger()->info("Everything loaded!");
        }


        }

        
    /**
        * @param PlayerJoinEvent $event
        *
        * @priority HIGHEST
        * @ignoreCancelled true
        */
        
    function onJoin(PlayerJoinEvent $event) {

            
    $player $event->getPlayer();
            
    $name $player->getDisplayName();

            if (
    $player->isOp()) {

                
    $this->getServer()->broadcastMessage("Hello! Guys," .$name." [ADMIN] joined the game!");
            }

            else {
                        
    $this->getServer()->broadcastMessage("Hello! Guys, ".$name." [DEFAULT] joined the game!");


        }

    }
    is my code now
    Last edited by a moderator: Sep 1, 2014
  2. Tuff
    Offline

    Tuff Active Member

    Joined:
    Jan 25, 2014
    Posts:
    203
    Minecraft User:
    Roboroug2
    Shouldn't it be
    PHP:
    public function onJoin(PlayerJoinEvent $event) {
    instead of just function onJoin
    HyperGamers likes this.
  3. iJoshuaHD
    Offline

    iJoshuaHD Notable Member Plugin Developer

    Joined:
    Nov 7, 2013
    Posts:
    1,167
    Plugins:
    4
    Minecraft User:
    iJoshuaHD
    use $player instead of $name.
  4. HyperGamers
    Offline

    HyperGamers New Member

    Joined:
    Aug 16, 2014
    Posts:
    16
    Minecraft User:
    HyperGamers
    I'll try again tomorrow.
  5. HyperGamers
    Offline

    HyperGamers New Member

    Joined:
    Aug 16, 2014
    Posts:
    16
    Minecraft User:
    HyperGamers
    Parse error: syntax error, unexpected 'public' (T_PUBLIC) in /PocketMine-MP/plugins/JoinNotification/src/JoinNotification/Main.php on line 28

  6. HyperGamers
    Offline

    HyperGamers New Member

    Joined:
    Aug 16, 2014
    Posts:
    16
    Minecraft User:
    HyperGamers
  7. HyperGamers
    Offline

    HyperGamers New Member

    Joined:
    Aug 16, 2014
    Posts:
    16
    Minecraft User:
    HyperGamers
    Last edited: Sep 1, 2014
  8. HyperGamers
    Offline

    HyperGamers New Member

    Joined:
    Aug 16, 2014
    Posts:
    16
    Minecraft User:
    HyperGamers
    Do I have to remove or add anything to this part:

    $player = $event->getPlayer();
    $name = $player->getDisplayName();

    Maybe something like $player = $event->isOp();
    64FF00 likes this.
  9. Tuff
    Offline

    Tuff Active Member

    Joined:
    Jan 25, 2014
    Posts:
    203
    Minecraft User:
    Roboroug2
    Dude, you put the "}" in the wrong spot. Move one of the ones after the onEnable function down to the very bottom. You have been excluding the function from your main class.
    64FF00 likes this.
  10. iJoshuaHD
    Offline

    iJoshuaHD Notable Member Plugin Developer

    Joined:
    Nov 7, 2013
    Posts:
    1,167
    Plugins:
    4
    Minecraft User:
    iJoshuaHD
    newbie problems. we have been there :D
    64FF00 likes this.
  11. Tuff
    Offline

    Tuff Active Member

    Joined:
    Jan 25, 2014
    Posts:
    203
    Minecraft User:
    Roboroug2
    Made a pull request.
    64FF00 likes this.
  12. HyperGamers
    Offline

    HyperGamers New Member

    Joined:
    Aug 16, 2014
    Posts:
    16
    Minecraft User:
    HyperGamers
  13. LDX
    Offline

    LDX Notable Member Plugin Developer

    Joined:
    Oct 2, 2013
    Posts:
    1,397
    Plugins:
    14
    Jon and HyperGamers like this.
  14. Tuff
    Offline

    Tuff Active Member

    Joined:
    Jan 25, 2014
    Posts:
    203
    Minecraft User:
    Roboroug2
    I solved the final one, :p
    LDX and HyperGamers like this.
  15. HyperGamers
    Offline

    HyperGamers New Member

    Joined:
    Aug 16, 2014
    Posts:
    16
    Minecraft User:
    HyperGamers
    I was saving the best till last! A very special thanks to @LDX for solving all problems.

    The reason I forgot because I did not recognise your name on GitHub. Sorry.
    Jon, LDX and Tuff like this.

Share This Page

Advertisement