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

Solved Sign Enchant - Enchant problem

Discussion in 'Development' started by RyanShaw, Jan 1, 2018.

  1. RyanShaw

    RyanShaw Witch

    Messages:
    69
    PHP:
                                      EconomyAPI::getInstance()->reduceMoney($player$money);
                                      
    $type filter_var($text[1], FILTER_SANITIZE_NUMBER_INT);
                                      
    $level filter_var($text[3], FILTER_SANITIZE_NUMBER_INT);
                                      
    $enchantment Enchantment::getEnchantment($type);
                                      
    $enchInstance = new EnchantmentInstance($enchantment$level);
                                      
    $item $player->getInventory()->getItemInHand();
                                      
    $item -> addEnchantment($enchInstance);
                                      
    $player->sendMessage("§aYou have successfully bought $type $level for $$money");
    Im trying to sell enchants using signs, it filters the text fine and thats shown in the message sent at the end but for whatever reason its just not putting the enchant im selling on the item in the players hand. Im getting no errors when i run this code at all and im on the latest version of pocketmine.. any help or ideas will be appreciated, ive been stuck on this one for a while now
     
  2. _XHazardX_

    _XHazardX_ Spider Jockey

    Messages:
    33
    GitHub:
    XHazardX420
    Add $player->getInventory()->setItemInHand($item);
     
    xXNiceAssassinlo YT and RyanShaw like this.
  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.