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

Getting an Item

Discussion in 'Development' started by RoyalMCPE, Jan 26, 2017.

  1. RoyalMCPE

    RoyalMCPE Slime

    Messages:
    87
    Wasn't the only issue but I did figure it out but now when I send the message it gives me this error

    Code:
    Error: "Call to a member function sendMessage() on null" (EXCEPTION) in "/plugins/ApocalypseCore_v0.1BETA/src/RoyalMCPE/ApocalypseCore/Events/WeeklyRewardEvents" at line 35
     
  2. wolfdale

    wolfdale Zombie Pigman

    Messages:
    535
    GitHub:
    diamond-gold
    Can you update your code on previous post?
     
  3. RoyalMCPE

    RoyalMCPE Slime

    Messages:
    87
    PHP:
    public function onTransaction(InventoryTransactionEvent $e) {
            
    $transactions $e->getTransaction ()->getTransactions ();
            
    $player null;
            
    $hopperinv null;
            
    $action null;
            foreach ( 
    $transactions as $transaction ) {
                if ((
    $inv $transaction->getInventory ()) instanceof HopperInventory) {
                    foreach ( 
    $inv->getViewers () as $assumed )
                        if (
    $assumed instanceof Player) {
                            
    $player $assumed;
                            
    $hopperinv $inv;
                        }
                }
                
    $action $transaction;
            }
            
    $e->setCancelled ();
            
    $item $action->getTargetItem ();
            if (
    $item->getName () === "Test") {
                
    $player->sendMessage "Test" );
            }
        }
     
  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.