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

Cancel inventory move items

Discussion in 'Development' started by Error202, Apr 26, 2019.

  1. Error202

    Error202 Spider Jockey

    Messages:
    39
    How I can cancel moving inventory items and opening inventory?
     
    Last edited: Apr 26, 2019
  2. neb16

    neb16 Witch

    Messages:
    71
    GitHub:
    developerneb101
    Try this:

    PHP:
    use pocketmine\event\inventory\InventoryOpenEvent;


     public function 
    open_inventory(InventoryOpenEvent $event){
          
    $event->setCancelled();
          
      }
    }
     
  3. radondev

    radondev Silverfish

    Messages:
    21
    GitHub:
    radondev
  4. Error202

    Error202 Spider Jockey

    Messages:
    39
    I can`t set inventory items when I cancel EntityInventoryChangeEvent or InventoryOpenEvent
     
  5. radondev

    radondev Silverfish

    Messages:
    21
    GitHub:
    radondev
    Simple workaround:
    When editing the inventory, add players to an array. In the events, search for the player in the array. This way you can bypass these events
     
  6. Levi

    Levi Skeleton

    Messages:
    955
    GitHub:
    captainleviftw
    tf this shit to do with what OP wants
     
  7. neb16

    neb16 Witch

    Messages:
    71
    GitHub:
    developerneb101
    He said he wanted to cancel opening an inventory
     
    Levi likes this.
  8. Levi

    Levi Skeleton

    Messages:
    955
    GitHub:
    captainleviftw
    Oop my bad
     
  9. neb16

    neb16 Witch

    Messages:
    71
    GitHub:
    developerneb101
    Ehh its good lol
     
  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.