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

How would I send a Tip on PlayerJoinEvent?

Comments in 'Plugin Development' started by SirGamer, Nov 26, 2015.

  1. SirGamer
    Offline

    SirGamer New Member

    Joined:
    Nov 26, 2015
    Posts:
    5
    Minecraft User:
    SirGamer
    How would I send a Tip on PlayerJoinEvent?

    Thanks,

    SirGamer.
  2. CraftYourBukkit
    Offline

    CraftYourBukkit Notable Member Plugin Developer

    Joined:
    Jan 20, 2015
    Posts:
    1,022
    Plugins:
    2
    Minecraft User:
    CraftYourBukkit
    Same way as in every other event/whatever.
  3. DevWars
    Offline

    DevWars Banned

    Joined:
    Nov 7, 2015
    Posts:
    28
    Minecraft User:
    PmServer
    No
    This
    PHP:
     public function Player(PlayerJoinEvent $event) {
            
    $player $event->getPlayer();
            
    $name $player->getName();
            
    $event->setJoinMessage(""); #dont Type Message Here !
            
    $player->sendTip("$name Join The Game !");
  4. Gamecrafter
    Offline

    Gamecrafter

    Joined:
    Nov 20, 2014
    Posts:
    978
    Plugins:
    9
    That wasn't very helpful. You could have gave him the code... :p
    PHP:
    public function onJoin(\pocketmine\event\player\PlayerJoinEvent $event){
        
    $event->getPlayer()->sendTip("message");
    }
    Bad syntax detected. You forgot a closing bracket. Let us handle this. ;)
    Primus and SirGamer like this.
  5. DevWars
    Offline

    DevWars Banned

    Joined:
    Nov 7, 2015
    Posts:
    28
    Minecraft User:
    PmServer
    this to
    PHP:
    public function Player(PlayerJoinEvent $event) {
            foreach (
    $this->getServer()->getOnlinePlayers() as $player) {
            
    $name $player->getName();
            
    $event->setJoinMessage(""); #dont Type Message Here !
            
    $player->sendTip("$name Join The Game !");
       
    }}
  6. DevWars
    Offline

    DevWars Banned

    Joined:
    Nov 7, 2015
    Posts:
    28
    Minecraft User:
    PmServer
    Ok this Simple :)
  7. CraftYourBukkit
    Offline

    CraftYourBukkit Notable Member Plugin Developer

    Joined:
    Jan 20, 2015
    Posts:
    1,022
    Plugins:
    2
    Minecraft User:
    CraftYourBukkit
    Well, he asked for the specific code in PlayerJoinEvent, so I thought he knows the "normal" code for it:)
    Gamecrafter likes this.
  8. SirGamer
    Offline

    SirGamer New Member

    Joined:
    Nov 26, 2015
    Posts:
    5
    Minecraft User:
    SirGamer
    Thanks for the help everyone!

    But how would I send a tip to every player?

    E.g. $name Joined the game!
  9. CraftYourBukkit
    Offline

    CraftYourBukkit Notable Member Plugin Developer

    Joined:
    Jan 20, 2015
    Posts:
    1,022
    Plugins:
    2
    Minecraft User:
    CraftYourBukkit
    PHP:
    foreach($this->getServer()->getOnlinePlayers() as $p){
       
    $p->sendTip("Your Tip");
    }
  10. SirGamer
    Offline

    SirGamer New Member

    Joined:
    Nov 26, 2015
    Posts:
    5
    Minecraft User:
    SirGamer
    Ah, I see. Thanks for the help!
  11. CraftYourBukkit
    Offline

    CraftYourBukkit Notable Member Plugin Developer

    Joined:
    Jan 20, 2015
    Posts:
    1,022
    Plugins:
    2
    Minecraft User:
    CraftYourBukkit
    You're welcome, like please:)
    Khaled098 likes this.
  12. Hotshot_9930
    Offline

    Hotshot_9930 Notable Member Plugin Developer

    Joined:
    May 26, 2014
    Posts:
    665
    Plugins:
    2
    Minecraft User:
    HotshotHD
    This would just send a tip to the player that is joining. If you were trying to make it broadcast a tip to the entire server, the correct code would be:
    PHP:
    public function onJoin(PlayerJoinEvent $event) {
      
    $event->setJoinMessage(null);
      Foreach(
    $this->getServer()->getOnlinePlayers() as $p) {
        
    $p->sendTip($event->getPlayer()->getName() . " Has joined the game");
      }
    }
  13. CraftYourBukkit
    Offline

    CraftYourBukkit Notable Member Plugin Developer

    Joined:
    Jan 20, 2015
    Posts:
    1,022
    Plugins:
    2
    Minecraft User:
    CraftYourBukkit
    He didn't ask for a tip to everyone when that Post was made.. He posted the code @SirGamer asked for, so why do you correct him when nothing is wrong?
    Jelly9912 likes this.
  14. Hotshot_9930
    Offline

    Hotshot_9930 Notable Member Plugin Developer

    Joined:
    May 26, 2014
    Posts:
    665
    Plugins:
    2
    Minecraft User:
    HotshotHD
    That might be so. But I don't see anything wrong with giving extra help. I didnt correct him, i simply gave another possibility of his code.
    That could have helped someone or even the guy who made this thread that might have been wondering how to do it.
  15. xpyctum
    Offline

    xpyctum Active Member Plugin Developer

    Joined:
    Jan 13, 2014
    Posts:
    292
    Plugins:
    4
    Minecraft User:
    tylerdisney
    PHP:
    public function onJoin(PlayerJoinEvent $event) {
         
    $event->setJoinMessage(null);
         
    $this->getServer()->broadcastTip("message");
    }
    AndrewBit, Primus and Legoboy0215 like this.

Share This Page

Advertisement