Inventory Help

Discussion in 'Plugin Development' started by 8thDimension, Aug 2, 2011.

Thread Status:
Not open for further replies.
  1. Offline

    8thDimension

    Hello, I'm working on a plugin that reads from signs and takes a few items from a players inventory depending on what's written on the sign.

    Now, while what I'm using is working... If the sign wants to take 1 diamond... and a player has a stack of diamonds it won't work. For it to work, the player has to have 1 diamond all by itself.

    Anyway on how to fix this?

    Thanks in advance :)
     
  2. Offline

    Nitnelave

    Well, you could check for the total number of diamonds he has in his inventory, take them out, and then give him back everything but one. Or you could just find a stack big enough, delete it, and put a new one a bit smaller. If you need some code, you can look at the source for giftSend, in my signature.
     
  3. Offline

    8thDimension

    Hmm, I'll try those out. Thanks :3

    Derp... I still don't understand :L Sorry for sounding like a noob... But can anyone explain to me briefly on how to fix this?

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 18, 2016
  4. @8thDimension Just use the inventory methods in my Extras library if you're having trouble :)
     
  5. Offline

    Nitnelave

    Well, an inventory in a bunch of ItemStacks. Loop over them, check if they are of the right type (and data? it depends), then check their number against the number you want to take. If it is inferior or equal, delete the stack. If it is superior, delete the stack and add a new one with the amount left (number in the stack - number to take).
     
Thread Status:
Not open for further replies.

Share This Page