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

Solved stdClass() error

Discussion in 'Development' started by ItzAribie, Nov 2, 2017.

  1. ItzAribie

    ItzAribie Spider Jockey

    Messages:
    41
    hello, I have an error that tells me "Undefined property: stdClass::$entityRuntimeId "
    but I dont know how to solve this problem.


    PHP:
     /**
         * @param DataPacketReceiveEvent $event
         * @return bool
         */
        
    public function onPacketReceived(DataPacketReceiveEvent $event)
        {
            
    $pk $event->getPacket();

            if (
    $pk instanceof InventoryTransactionPacket) {

                (isset(
    $this->entity[$pk->trData->entityRuntimeId])){
                
    $citizen $this->entity[$pk->trData->entityRuntimeId];

                if (!isset(
    $this->command[$event->getPlayer()->getName()])) {
                    
    $citizen->commandExecute($event->getPlayer());
                    return 
    true;
                }
            }
        }
        }
     
  2. Muqsit

    Muqsit Chicken

    Messages:
    1,548
    GitHub:
    muqsit
    The error answers your question.
    According to https://github.com/pmmp/PocketMine-.../mcpe/protocol/InventoryTransactionPacket.php, InventoryTransactionPacket::$trData->entityRuntimeId is set only if InventoryTransactionPacket::$transactionType returns InventoryTransactionPacket::TYPE_USE_ITEM_ON_ENTITY. So you'll need to check that before calling trData->entityRuntimeId.
     
    Last edited: Nov 2, 2017
  3. ItzAribie

    ItzAribie Spider Jockey

    Messages:
    41
    Solved Thanks you.
     
  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.