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

How to remember players

Discussion in 'Plugin Help' started by FanTSM, Feb 26, 2019.

  1. FanTSM

    FanTSM Spider Jockey

    Messages:
    28
    GitHub:
    nam2k
    I want When players join they will receive items. but will not work on the next visit
     
  2. SalmonDE

    SalmonDE Zombie Pigman

    Messages:
    739
    GitHub:
    SalmonDE
    Assuming your server saves player data, I suggest checking Player->hasPlayedBefore() in an event listener of PlayerJoinEvent:

    Example:
    PHP:
    function onPlayerJoin(\pocketmine\event\player\PlayerJoinEvent $event): void{
        if(!
    $event->getPlayer()->hasPlayedBefore()){
            
    $item = \pocketmine\item\ItemFactory::get(\pocketmine\item\Item::STONE);
            
    $event->getPlayer()->getInventory()->addItem($item);
        }
    }
     
    HimbeersaftLP likes this.
  3. FanTSM

    FanTSM Spider Jockey

    Messages:
    28
    GitHub:
    nam2k
    Oh.thanks you
     
  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.