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 Draglor56, Apr 27, 2020.

  1. Draglor56

    Draglor56 Silverfish

    Messages:
    24
    PHP:
    public function Transaction(InventoryTransactionEvent $event){

    $event->setCancelled(true):

    }
    Hello I want to cancel the event if the Player is gamemode 1. Can Someone help me?
     
  2. HimbeersaftLP

    HimbeersaftLP Fish

    Messages:
    2,402
    GitHub:
    HimbeersaftLP
    PHP:
    public function onInventoryTransaction(InventoryTransactionEvent $event){
      if (
    $event->getTransaction()->getSource()->getGamemode() === Player::CREATIVE) {
        
    $event->setCancelled(true);
      }
    }
     
  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.