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

SlotInventory

Discussion in 'Development' started by abimalek, Nov 12, 2017.

  1. abimalek

    abimalek Witch

    Messages:
    74
    GitHub:
    megagastpvp
    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
     
  2. jasonwynn10

    jasonwynn10 Moderator Poggit Reviewer

    Messages:
    1,489
    GitHub:
    jasonwynn10
    What do you mean you don't know? Didn't you test it?
     
  3. abimalek

    abimalek Witch

    Messages:
    74
    GitHub:
    megagastpvp
    I did try it but it did nothing
     
  4. jasonwynn10

    jasonwynn10 Moderator Poggit Reviewer

    Messages:
    1,489
    GitHub:
    jasonwynn10
    Please show the code you tested
     
  5. abimalek

    abimalek Witch

    Messages:
    74
    GitHub:
    megagastpvp
  6. abimalek

    abimalek Witch

    Messages:
    74
    GitHub:
    megagastpvp
  7. jasonwynn10

    jasonwynn10 Moderator Poggit Reviewer

    Messages:
    1,489
    GitHub:
    jasonwynn10
    okay, so you are testing to see if a player inserted a specific item in that specific slot correct?
     
  8. abimalek

    abimalek Witch

    Messages:
    74
    GitHub:
    megagastpvp
  9. abimalek

    abimalek Witch

    Messages:
    74
    GitHub:
    megagastpvp
  10. abimalek

    abimalek Witch

    Messages:
    74
    GitHub:
    megagastpvp
    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
     
  11. Muqsit

    Muqsit Chicken

    Messages:
    1,548
    GitHub:
    muqsit
    • 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.
     
    jasonwynn10 likes this.
  12. abimalek

    abimalek Witch

    Messages:
    74
    GitHub:
    megagastpvp
    cant I do $item->getId()
     
    jasonwynn10 likes this.
  13. abimalek

    abimalek Witch

    Messages:
    74
    GitHub:
    megagastpvp
    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
     
  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.