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!


    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 Inventory list (Detect, Add to list, if the item is, give back)

Discussion in 'Skript' started by Dabriel, Aug 29, 2018.

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

    Dabriel Member

    Aug 13, 2018
    Likes Received:
    Alright, so I'm trying to create this really cool feature on my server. It's not happening tho.
    I'm a beginner in Skript so I need help. Why not create this Skript together?
    So what I have in mind, is making some kind of blacksmith.

    So it's a GUI, obv. The first row until slot 7, should be the list that players can place the items in.
    The items that are placed in that list (slots) are gonna be added to the items list, like
    Code (Skript):
    1. {blacksmith.%player%::items::*} -- Just an example.

    Now when the items are in the slots, the IF condition gonna take a place in the code.
    So let's say, you need common keys to make 1 uncommon key.
    if you place 3 keys in that GUI, the items are gonna get added to the items list, so if {blacksmith.%player%::items::*} has those 3 items, and the player clicks on the green dye
    It's gonna clear the slots from 0 to 7, give the player the uncommon key, and delete the items list.

    But if the player puts only 2 out of 3 items in, it's gonna clear the slots from 0 to 7, give all the items in the list back and delete the list.

    So what's the best way to do so? I mean, how to create a list and do the if condition?
    This might sound like too much, if we make it, it might help a lot of people, and give some new ideas.

    Thanks :emoji_slight_smile:
    --- Double Post Merged, Aug 30, 2018, Original Post Date: Aug 29, 2018 ---
    At least just help making the list for the slots :emoji_frowning:
  2. Best Answer:
    Post #2 by PatoFrango, Sep 1, 2018
  3. PatoFrango

    PatoFrango Active Member

    Jul 12, 2017
    Likes Received:
    Help is on the way, Dabriel.

    I've coded your entire request, I only have one question: What would happen if players put more than 3 common keys on the slots?

    EDIT: Nevermind, I'm in a hurry, take it, I wrote it so it would return all the common keys even if they're more than 3 (just like if they were less than 3).

    Note: it includes a command to auto-give you a common key so you can test it, don't forget to delete that later, or else players will have free common keys at-their-service lol. Good script idea tho.

    P.S. You actually don't need any array. It's all about slot looping.

    Code (Skript):
    1. options:
    2.     readyButton: &a&lReady
    3.     commonKeyItem: iron nugget
    4.     uncommonKeyItem: gold nugget
    5.     commonKey: &7&lCommon Key
    6.     uncommonKey: &c&lUncommon Key
    8. command /blacksmithgui:
    9.     trigger:
    10.         open chest with 3 rows named "&5&lBlacksmith" to player
    11.         set slot 8 of player's current inventory to light green dye named "{@readyButton}"
    12.         set {_count} to 9
    13.         loop 18 times:
    14.             set slot {_count} of player's current inventory to black stained glass named " "
    15.             add 1 to {_count}
    17. on inventory click:
    18.     name of event-inventory is "&5&lBlacksmith"
    19.     if event-slot is not air:
    20.         cancel event
    21.         if name of event-slot is "{@readyButton}":
    22.             set {_count} and {_common} to 0
    23.             loop 8 times:
    24.                 if name of slot {_count} of event-inventory is "{@commonKey}":
    25.                     add 1 to {_common}
    26.                 add 1 to {_count}
    27.             if {_common} is 3:
    28.                 set slot 0, 1, 2, 3, 4, 5, 6 and 7 of event-inventory to air
    29.                 give {@uncommonKeyItem} named "{@uncommonKey}" to player
    30.             else:
    31.                 set {_count} to 0
    32.                 loop 8 times:
    33.                     give slot {_count} of event-inventory to player
    34.                     add 1 to {_count}
    35.                 set slot 0, 1, 2, 3, 4, 5, 6 and 7 of event-inventory to air
    37. on inventory close:
    38.     name of event-inventory is "&5&lBlacksmith"
    39.     set {_count} to 0
    40.     loop 8 times:
    41.         give slot {_count} of event-inventory to player
    42.         add 1 to {_count}
    44. command /givecommonkey:
    45.     trigger:
    46.         give {@commonKeyItem} named "{@commonKey}" to player
    #2 PatoFrango, Sep 1, 2018
    Last edited: Sep 1, 2018
    • Winner Winner x 1
  4. Dabriel

    Dabriel Member

    Aug 13, 2018
    Likes Received:

    Thank you so very much for this masterpiece! It's perfect! I didn't think anyone would do it
    Thank you so much
    • Like Like x 1
Thread Status:
Not open for further replies.

Share This Page