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

Inventory Size

Discussion in 'Development' started by Ngao, May 24, 2017.

  1. Ngao

    Ngao Silverfish

    Messages:
    18
    PHP:
    <?php

    namespace MF;

    use 
    pocketmine\plugin\PluginBase;
    use 
    pocketmine\Player;
    use 
    pocketmine\Inventory;
    use 
    pocketmine\command\Command;
    use 
    pocketmine\command\CommandSender;
    use 
    ngocchinhofficial\NapThe\NapThe;
    use 
    ngocchinhofficial\NapThe\NapTheAPI;
    use 
    pocketmine\event\player\PlayerRespawnEvent;
    use 
    pocketmine\Server;

    Class 
    IS extends PluginBase{
       
        public 
    $napThe;

    public function 
    onEnable(){
        
    $this->napThe $this->getServer()->getPluginManager()->getPlugin("NapThe");
    }

    public function 
    onCommand(CommandSender $senderCommand $cmd$label, array $args){
            switch(
    $cmd->getName()){
              case 
    "isize":
                
    $sender->getInventory()->setSize(45);
                
    $sender->sendMessage("§8[§eInventory§8] §fТúi đồ của bạn tăng 45 chỗ trống");      
                     
    $this->saveYml();          
              return 
    true;
         
              case 
    "isize1":
                if (!
    $this->napThe->api->take($sender->getName(), abs(35))){
                
    $sender->sendMessage("§a- Không đủ Point để tăng thêm kho");
                return 
    false;
            }
                
    $sender->getInventory()->setSize(65);
                
    $sender->sendMessage("§8[§eInventory§8] §fТúi đồ của bạn tăng 65 chỗ trống");
                 
    $this->saveYml();
              return 
    true;
         
              case 
    "isize2":
                if (!
    $this->napThe->api->take($sender->getName(), abs(40))){
                
    $sender->sendMessage("§a- Không đủ Point để tăng thêm kho");
                return 
    false;
            }
                
    $sender->getInventory()->setSize(70);
                
    $sender->sendMessage("§8[§eInventory§8] §fТúi đồ của bạn tăng 70 chỗ trống");  
                
    $this->saveYml();          
              return 
    true;
              default:
                   return 
    false;
    }
    }
    public function 
    onDisable(){}
    }
    ?>
    This is my code
    And how to save inventory size when player join
     
  2. Amon28

    Amon28 Slime

    Messages:
    76
    GitHub:
    amon28
    Use player join event
     
  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.