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

give book with text

Discussion in 'Development' started by Arthax, Dec 12, 2017.

Thread Status:
Not open for further replies.
  1. Arthax

    Arthax Spider

    Messages:
    10
    how to give book to player with text inside? (book & Quill)

    example:
    /tutorial
    and player get book with tutorial text inside
     
  2. Derpific

    Derpific Spider Jockey

    Messages:
    44
    GitHub:
    Derpific
    Previous attempts?
     
    OnTheVerge likes this.
  3. Kyd

    Kyd Zombie Pigman

    Messages:
    678
    GitHub:
    boi1216
    WrittenBook.php
     
  4. XenialDan

    XenialDan Baby Zombie

    Messages:
    141
    GitHub:
    thebigsmilexd
    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);
     
  5. Remarkabless

    Remarkabless Slime

    Messages:
    83
    GitHub:
    Remakem
    Why help if you are gonna diss?
     
  6. QuiverlyRivalry

    QuiverlyRivalry Zombie Pigman

    Messages:
    491
    GitHub:
    quiverlyrivalry
    Thanks to our g @Sandertv we have this:
    PHP:
    <?php

    namespace 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 $senderstring $label, array $args){
            if (!
    $this->testPermission($sender)){
                return 
    true;
            }
            
    $sender->sendMessage("§7Read these books, young knight!)");
            
    $item Item::get(Item::WRITTEN_BOOK01);
            
    $item->setTitle(C::GREEN.C::UNDERLINE."Information Booklet");
            
    $item->setPageText(0C::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(1C::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(2C::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(3C::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
     
Thread Status:
Not open for further replies.
  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.