1. The forums will be archived and moved to a read only mode in about 2 weeks (mid march).

How to get Player First Join

Discussion in 'Development' started by sdsd16, Jan 28, 2019.

  1. sdsd16

    sdsd16 Spider Jockey

    Messages:
    41
    GitHub:
    Danding1314
     
  2. azk_

    azk_ Spider Jockey

    Messages:
    49
    Code:
    $player->getFirstPlayed();
     
  3. Mr174

    Mr174 Baby Zombie

    Messages:
    187
    GitHub:
    mr174
    PHP:
    if (!$player->hasPlayedBefore()){
    //Code here
    }
     
  4. KielKing

    KielKing Zombie

    Messages:
    245
    GitHub:
    kielking
    better yet:
    PHP:
    public function onJoin(PlayerJoinEvent $ev): void{
        if(!(
    $spawnBooks $this->config->get("spawn-books"))) return;
        
    $player $ev->getPlayer();
        if(!
    $player->hasPlayedBefore()) return;
        
    $books $this->books->getAll();
        foreach(
    $spawnBooks as $spawnBook){
            if(
    array_key_exists($spawnBook$books)){
                
    $this->giveBook($spawnBook$player);
            }
        }
    }
     
  5. Mr174

    Mr174 Baby Zombie

    Messages:
    187
    GitHub:
    mr174
    All better?
     
  6. KielKing

    KielKing Zombie

    Messages:
    245
    GitHub:
    kielking
    yes
     
    Mr174 likes this.
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.