How to get Player First Join

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

  1. sdsd16

    sdsd16 Spider Jockey

    Messages:
    27
    GitHub:
    Danding1314
     
  2. azk_

    azk_ Spider Jockey

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

    Mr174 Spider Jockey

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

    KielKing Zombie

    Messages:
    213
    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 Spider Jockey

    Messages:
    30
    GitHub:
    Mr174
    All better?
     
  6. KielKing

    KielKing Zombie

    Messages:
    213
    GitHub:
    kielking
    yes
     
    Mr174 likes this.

Share This Page

  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.