1. Welcome to skUnity!

    Welcome to skUnity! This is a forum where members of the Skript community can communicate and interact. Skript Resource Creators can post their Resources for all to see and use.

    If you haven't done so already, feel free to join our official Discord server to expand your level of interaction with the comminuty!

    Now, what are you waiting for? Join the community now!

  2. LOOKING FOR A VERSION OF SKRIPT?

    You can always check out our Wiki for downloads and any other information about Skript!

Dismiss Notice
This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Solved If amount of named item

Discussion in 'Skript' started by Xceislor, Nov 8, 2021.

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

    Xceislor Member

    Joined:
    Aug 4, 2021
    Messages:
    18
    Likes Received:
    0
    Code (Text):
    1. on inventory click:
    2.     if event-inventory = (metadata tag "minermerchant" of player):
    3.         cancel event
    4.         if amount of cobblestone with name "&7Cobblestone" in player's inventory >= 10:
    5.             broadcast "hi"

    This doesnt work as any cobblestone with a normal name adds to it.

     
    #1 Xceislor, Nov 8, 2021
    Last edited: Nov 8, 2021
  2. Best Answer:
    Post #5 by Xceislor, Nov 10, 2021
  3. TweedeKamer

    TweedeKamer Member

    Joined:
    Sep 6, 2021
    Messages:
    23
    Likes Received:
    1
    Code (Text):
    1. if amount of cobblestone named "Test" in player's inventory is greater than or equal to 10:
    2.         broadcast "hi"
    This works fine for me
     
  4. Xceislor

    Xceislor Member

    Joined:
    Aug 4, 2021
    Messages:
    18
    Likes Received:
    0
    Does it also work with normal cobblestone or with only ones named "Test"?
     
  5. oToghty

    VIP Supporter +

    Joined:
    Sep 1, 2020
    Messages:
    142
    Likes Received:
    5
    You can use
    Code (Text):
    1. if amount of all cobblestone in player's inventory where [name of input is ""] >= 10:
     
  6. Xceislor

    Xceislor Member

    Joined:
    Aug 4, 2021
    Messages:
    18
    Likes Received:
    0
    Didn't work for me
    --- Double Post Merged, Nov 10, 2021, Original Post Date: Nov 10, 2021 ---
    Fixed it!

    Code (Text):
    1.  
    2. on inventory click:
    3.     if event-inventory = (metadata tag "minermerchant" of player):
    4.         cancel event
    5.         if index of event-slot is 9:
    6.             loop all items in player's inventory:
    7.                 if loop-item's name is "&7Cobblestone":
    8.                     set {_c} to amount of loop-item in player's inventory
    9.                     if {_c} >= 10:
     
Thread Status:
Not open for further replies.

Share This Page

Loading...