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

Get EnchantID on args

Discussion in 'Help' started by ZackyVN, Dec 23, 2018.

  1. ZackyVN

    ZackyVN Baby Zombie

    Messages:
    150
    Ok so i have this error code [when i did it i felt i wrong]
    PHP:
    if($mymoney >= $args[1]*1000){
    $phuphep = new Enchantment(Enchantment::$args[0]);
    $item->addEnchantment(new EnchantmentInstance($phuphep$args[1]));
    $this->economyAPI->reduceMoney($sender$args[1]*1000);
    $sender->sendMessage("§l§aHero§bMC§e>§r§a Bạn đã mua phù phép§e " $args[0] . "§a level§e " $args[1] . "§a với giá" $args[1]*1000);
    }else{
    $sender->sendMessage("§l§aHero§bMC§e>§r§c Không đủ tiền mua enchant!");
    Of course it error can someone help me get a id enchant on $args[0]
     
  2. Kkora

    Kkora Baby Zombie

    Messages:
    189
    GitHub:
    shisui203
    Use this. BuyEnchant plugin::
    PHP:
        public function onCommand(CommandSender $sCommand $cmd$label, array $args) {
           
            if(
    $cmd->getName() == "muaec") {
               
              if(isset(
    $args[0]) && isset($args[1])) {
                 
                  if(
    is_numeric($args[0])) {
                     
                    if(
    is_numeric($args[1])) {
                       
                      if(
    $this->eco->myMoney($s->getName()) >= $args[1] ."000") {
                         
                         
            
    $enchantLevel $args[1] <= 100 $args[1] : 1;
            
    $enchantId $args[0];
           
           
            
    $enchantment Enchantment::getEnchantment($enchantId);
           
            if(
    $enchantment->getId() === Enchantment::TYPE_INVALID){
               
                
    $enchantment Enchantment::getEnchantmentByName($enchantId);
               
                if(
    $enchantment->getId() === Enchantment::TYPE_INVALID){
                    
    $s->sendMessage("§c>>§e Không thấy loại§d Phù phép§e bạn yêu cầu");
                    return 
    true;
                }
            }
           
            
    $enchantment->setLevel($enchantLevel);
            
    $item $s->getInventory()->getItemInHand();
            if(
    $item->getId() <= 0){
                
    $s->sendMessage("§c>>§e Bạn phải cầm đồ khi phù phép");
                return 
    true;
            }
           
            if(
    Enchantment::getEnchantAbility($item) === 0){
                
    $s->sendMessage("§c>>§e Không thể§d Phù phép");
                return 
    true;
            }
            
    $item->addEnchantment($enchantment);
            
    $s->getInventory()->setItemInHand($item);
                           
                            
    $this->eco->reduceMoney($s->getName(), $args[1] ."000");
                           
                            
    $s->sendMessage("§c>>§d Phù phép§a thành công! Tiền§d Phù phép§a đã bị trừ vào tài khoản của bạn§a!");
                            return 
    true;
                      } else {
                          
    $s->sendMessage("§c>>§e Không thể§d Phù phép§e vì không đủ tiền");
                          return 
    false;
                      }
                    } else {
                        
    $s->sendMessage("§c>>§e Không thấy loại§d Phù phép§e bạn yêu cầu vì Cấp độ §dPhù phép§e phải là số");
                        return 
    false;
                    }
                 
              } else {
                  
    $s->sendMessage("§c>>§e ID phải là số");
                 return 
    false;
              }
            } else {
                
    $s->sendMessage("§c>>§a Cách dùng: §e/muaec <Tên Enchant|ID> <Cấp độ>");
                return 
    false;
            }
            }
    This plugin coded when API 2.0.0. Check if it has any error.
     
  3. ZackyVN

    ZackyVN Baby Zombie

    Messages:
    150
    Yes the enchantment now requier EnchantmentInstance
     
  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.