How to remember players

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

  1. FanTSM

    FanTSM Spider

    Messages:
    12
    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:
    736
    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

    Messages:
    12
    GitHub:
    nam2k
    Oh.thanks you
     

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.