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

Check when player connected for the first time

Comments in 'Plugin Development' started by Flabe, Feb 13, 2016.

  1. Flabe
    Offline

    Flabe Active Member

    Joined:
    Nov 17, 2015
    Posts:
    147
    Minecraft User:
    Flabe231
    Hello guys i am making a plugin that sends message to player when he connect !!!ONLY!!! for the first time , how do i detect it??
  2. Tim // robske Büba
    Offline

    Tim // robske Büba Notable Member

    Joined:
    Feb 26, 2014
    Posts:
    606
    Minecraft User:
    robske_110
    PHP:
        public function onPlayerJoinSteve(PlayerLoginEvent $e){
            
    $playerJoinName $e->getPlayer()->getName();
            
    //save it to an config read stuff...
        
    }
  3. MyNameIsTriXz
    Offline

    MyNameIsTriXz Notable Member

    Joined:
    Aug 17, 2015
    Posts:
    538
    Minecraft User:
    MyNameIsTriXz
    PHP:
    if($player->getFirstPlayed() == $player->getLastPlayed()){
    // code
    }
  4. Tim // robske Büba
    Offline

    Tim // robske Büba Notable Member

    Joined:
    Feb 26, 2014
    Posts:
    606
    Minecraft User:
    robske_110
    WHAT THERE ARE API FUNCTIONS FOR THAT
    lol
  5. MyNameIsTriXz
    Offline

    MyNameIsTriXz Notable Member

    Joined:
    Aug 17, 2015
    Posts:
    538
    Minecraft User:
    MyNameIsTriXz
  6. Tim // robske Büba
    Offline

    Tim // robske Büba Notable Member

    Joined:
    Feb 26, 2014
    Posts:
    606
    Minecraft User:
    robske_110
    Let me combine 1+1:
    PHP:
    public function onPlayerJoin(PlayerLoginEvent $e){
       if(
    $player->getFirstPlayed() == $player->getLastPlayed()){
       
    $player->sendMessage("Hi")}
    }
  7. MyNameIsTriXz
    Offline

    MyNameIsTriXz Notable Member

    Joined:
    Aug 17, 2015
    Posts:
    538
    Minecraft User:
    MyNameIsTriXz
    Oh wait sorry, I found an easier way:
    PHP:
    if($player->hasPlayedBefore() == false){
    Last edited: Feb 13, 2016
  8. MyNameIsTriXz
    Offline

    MyNameIsTriXz Notable Member

    Joined:
    Aug 17, 2015
    Posts:
    538
    Minecraft User:
    MyNameIsTriXz
    Gratulation, but... Syntax error on sendMessage() :D
  9. Tim // robske Büba
    Offline

    Tim // robske Büba Notable Member

    Joined:
    Feb 26, 2014
    Posts:
    606
    Minecraft User:
    robske_110
    Semicolons...
  10. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    MyNameIsTriXz likes this.

Share This Page

Advertisement