how to give book to player with text inside? (book & Quill) example: /tutorial and player get book with tutorial text inside
PHP: $pageId = 0; //First page $pageText = "Hello. This is a written book. I asked in a forum before i try to read and understand PocketMine's source code"; /** @var WrittenBook $item */ $item = ItemFactory::get(ItemIds::WRITTEN_BOOK); $item->setPageText($pageId,$pageText); $player->getInventory()->addItem($item);
Thanks to our g @Sandertv we have this: PHP: <?phpnamespace CRshit\Commands;use pocketmine\plugin\PluginBase;use pocketmine\event\player\PlayerJoinEvent;use pocketmine\event\player\PlayerQuitEvent;use pocketmine\Player;use pocketmine\Server;use pocketmine\event\Listener;use pocketmine\utils\TextFormat as C;use pocketmine\item\WrittenBook;use pocketmine\item\Item;use pocketmine\command\Command;use pocketmine\command\CommandSender;use CRshit\Main;class information extends Command{ public function __construct(){ parent::__construct("information"); $this->setDescription("Wondered how to play? Well use this command and your questions shall be fulfilled!"); $this->setAliases(["information"]); $this->setPermission("information.command"); } public function execute(CommandSender $sender, string $label, array $args){ if (!$this->testPermission($sender)){ return true; } $sender->sendMessage("§7Read these books, young knight!)"); $item = Item::get(Item::WRITTEN_BOOK, 0, 1); $item->setTitle(C::GREEN.C::UNDERLINE."Information Booklet"); $item->setPageText(0, C::GREEN.C::UNDERLINE."Whats a Kingdom?".C::BLACK."\n - A kingdom, is your home, its like a fations. Except bigger! \n - Kingdoms, have many members and a custom world! \n - Each kingdom has a king, this king is who you shall fight for!"); $item->setPageText(1, C::GREEN.C::UNDERLINE."How can my Kingdom win?". C::BLACK."\n - You can earn power in the weekly wars, and from PvPing enemy kingdoms! \n - You can earn power in our KOTH at warzone."); $item->setPageText(2, C::GREEN.c::UNDERLINE."How do I store my loot, and get loot?". C::BLACK."\n - Try doing /pv 1, for a vault! \n - Go to your kingdoms world, and make a base, skybase, or lair! \n - Make sure you raid other kingdoms bases!"); $item->setPageText(3, C::GREEN.c::UNDERLINE."Helpful Commands". C::BLACK."\n- /k \n - /warpme \n - /pv \n - /shop \n - /cpshop \n - /ulog"); $item->setAuthor("Server"); $sender->getInventory()->addItem($item); return true; }} This is mostly the same just change the letters, it does it on command /information, change that to what you need