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

Solved InventoryTransactionEvent problem

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

  1. ItzAribie

    ItzAribie Spider Jockey

    Messages:
    41
    Hello, I have tested my code but nothing is happening... Why ?

    PHP:
        public function onTransaction(InventoryTransactionEvent $e)
        {

            
    $transactions $e->getTransaction()->getInventories();
            
    $player null;
            
    $chestinv null;
            
    $action null;
            
    $item null;
            foreach (
    $transactions as $transaction) {
                
    $inv $transaction->getHolder()->getInventory();
                if (
    $inv instanceof ChestInventory) {
                    foreach (
    $inv->getViewers() as $assumed) {
                        if (
    $assumed instanceof Player) {
                            
    $player $assumed;
                            
    $chestinv $inv;
                            
    $action $transaction;
                            break 
    2;

                        }
                    }
                }
                foreach (
    $e->getTransaction()->getActions() as $inventoryAction) {
                    
    $item $inventoryAction->getSourceItem();

                }

                if (
    is_null($player ?? $chestinv ?? $action)) {
                    return;
                }

                if (
    $action instanceof SlotChangeAction) {


                    
    $slot $action->getSlot();


                    
    $this->Shopbuy($player$item$chestinv$slot);
                }
            }
        }
     
    Last edited: Nov 20, 2017
  2. Yexeed

    Yexeed Slime

    Messages:
    76
    I think we can start from this
     
  3. ItzAribie

    ItzAribie Spider Jockey

    Messages:
    41
    Noo.. please stop your thread I have modify the code for clean up I just forget a semicolon problem is not that you dont help me I dont have error.
     
    Last edited: Nov 20, 2017
  4. Kyd

    Kyd Zombie Pigman

    Messages:
    678
    GitHub:
    boi1216
    Debug with echo ?
     
  5. ItzAribie

    ItzAribie Spider Jockey

    Messages:
    41
    Nope I prefer var_dump
     
  6. ItzAribie

    ItzAribie Spider Jockey

    Messages:
    41
    Solved !!!!! :)
     
  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.