I'm working on improveing my friends plugin and I need to know how to check a specific slot in an anvil inventory I tried $inv->getSlot() but I don't know if that would work
I also tried that but I what to see if they put an item into slot 1 if they did what it is if its a book and its custom name is Gears it checks if the sender also put a sword into slot 2 if they did it adds the enchant to slot 2 and removes the book I what to know this because me and my friend are buying a customenchsnt plugin from Derpific and I what to add books to it
You're using an old version of PocketMine or maybe that's not even pmmp/PocketMine because InventoryTransactionEvent::getTransaction()->getTransactions() is not a method anymore. You definitely didn't import AnvilInventory class. $item = $transaction->getItem() must throw you an error. Figure out why. Even if you assume it to be $tr->getItem(), that method does not exist. That would be another error. Even if you assume it to be PHP: foreach($tr->getActions() as $action){ if($action instanceof SlotChangeAction){ $item = $action->getSourceItem(); if($item === 240){//<---- } }} $item === 240 will always return false because $item is always an Item instance, not an integer.
That helped a lot but I'm trying to check if they put an item into slot1 in the anvil inventory then I would what to check if they put something in slot2 if slot1 is a book my main problem is checking if they put something in slot2 after they put something in slot 1