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

InventoryTransactionEvent

Discussion in 'Development' started by SergeyIvanov, Apr 20, 2017.

  1. SergeyIvanov

    SergeyIvanov Witch

    Messages:
    59
    GitHub:
    sergeyivanov14
    Problem description
    When i use InventoryTransactionEvent in plugin, when i checking if player click item in chest he should to send message to him. But when player use item in PlayerInventory, working function when player use in chest.

    Steps to reproduce the bug
    Use this code:

    PHP:
    public function transactionEvent(\pocketmine\event\inventory\InventoryTransactionEvent $e){
    foreach(
    $e->getTransaction()->getTransactions() as $transaction){
    foreach(
    $e->getTransaction()->getInventories() as $inv){
    if(
    $inv->getHolder() instanceof \pocketmine\Player$p $inv->getHolder();
    elseif(
    $inv->getHolder() instanceof \pocketmine\tile\Chest$chest $inv->getHolder();
    if(
    $transaction->getTargetItem()->getId() == and $transaction->getTargetItem()->getDamage() == 0){
    $p->sendMessage("Working");
    }}}}
     
    Levi likes this.
  2. Zuruki

    Zuruki Baby Zombie

    Messages:
    118
    GitHub:
    zuruki
    open curly bracket on the elseif line dude!
     
  3. Levi

    Levi Skeleton

    Messages:
    955
    GitHub:
    captainleviftw
    where?
     
  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.