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 Limit the Number of Custom Crafting Recipe Uses?

Discussion in 'Skript' started by Selvati, Dec 19, 2017.

Tags:
Thread Status:
Not open for further replies.
  1. Selvati

    Selvati Active Member

    Joined:
    Jun 26, 2017
    Messages:
    190
    Likes Received:
    10
    I would like to know if anyone is aware of any methods to limit each player to only be able to use custom crafting recipes registered with skript a certain number of times, example, you make a custom recipe for bedrock, each player can craft it 3 times. Any suggestions?

     
  2. Best Answer:
    Post #9 by Selvati, Dec 21, 2017
  3. Aryaz25

    Aryaz25 Member

    Joined:
    Apr 6, 2017
    Messages:
    23
    Likes Received:
    0
    Code (Skript):
    1. on inventory click:
    2.     if clicked slot type is RESULT:
    3.         if name of clicked item contain "Awesome Bedrock":
    4.             if {bedrock.%player%} = 3:
    5.                 cancel event
    6.                 send "You cannot craft any more bedrock!"
    7.                 stop
    8.             add 1 to {bedrock.%player%}
    Dunno if that works, but you get the point...

    using Skellett addons
     
  4. Selvati

    Selvati Active Member

    Joined:
    Jun 26, 2017
    Messages:
    190
    Likes Received:
    10
    WOW! This is so simple yet very effective, thank you so much!
    --- Double Post Merged, Dec 20, 2017, Original Post Date: Dec 19, 2017 ---
    I get the error that RESULT cannot be compared to a slot type?
     
  5. Aryaz25

    Aryaz25 Member

    Joined:
    Apr 6, 2017
    Messages:
    23
    Likes Received:
    0
    Huh, thats wierd...

    https://docs.skunity.com/syntax/search/slot type

    The docs explained, that RESULT is for result slot in a furnace or crafting inventory.
    --- Double Post Merged, Dec 20, 2017, Original Post Date: Dec 20, 2017 ---
    So i tested it out by myself with these codes...

    Code (Skript):
    1. on inventory click:
    2.     if clicked slot type is RESULT:
    3.         if clicked item is iron axe:
    4.             if {axe.%player%} = 3:
    5.                 cancel event
    6.                 send "You cannot craft any more axes!"
    7.                 stop
    8.             add 1 to {axe.%player%}
    9.             send "successfully crafted axe"
    And it worked for me
    [​IMG]

    Are you sure you have the latest version of skellet?
     
  6. Snow-Pyon

    Snow-Pyon Well-Known Member

    Joined:
    Jan 25, 2017
    Messages:
    1,235
    Likes Received:
    176
    Medals:
    Well, if you made the recipe using TuSKe's Recipe Manager then it'd be as easy as:
    Code (Skript):
    1. on prepare item craft:
    2.  
    3.   if result item of event-recipe is stone named "test": #for example
    4.  
    5.     cancel event
    It'd work if you made it with skQuery and you have TuSKe, too.
     
  7. Pikachu

    Supporter Addon Developer

    Joined:
    Jan 25, 2017
    Messages:
    870
    Likes Received:
    139
    Medals:
    Please use list variables and uuids, especially when providing code for other people.
    upload_2017-12-20_3-36-21.png
     
  8. Selvati

    Selvati Active Member

    Joined:
    Jun 26, 2017
    Messages:
    190
    Likes Received:
    10
    --- Double Post Merged, Dec 20, 2017, Original Post Date: Dec 20, 2017 ---
    Here is what I have, only the error I posted above.


    Code (Skript):
    1. #Iron Pack Craft
    2. on script load:
    3.     register new shaped recipe for 10 iron ingot using iron ore, iron ore, iron ore, iron ore, coal, iron ore, iron ore, iron ore, iron ore
    4.    
    5. #Craft Limit Check
    6. on prepare item craft:
    7.     if result item of event-recipe is 10 iron ingot:
    8.         if {craft.ironpack.%player%} = 3:
    9.             cancel event
    10.             send "You cannot craft any more Rion Packs!"
    11.             stop
    12.         add 1 to {craft.ironpack.%player%}
    --- Double Post Merged, Dec 20, 2017 ---
    Whoops, I forgot to say this is the only error, "An on item craft event cannot be cancelled"
     
  9. Snow-Pyon

    Snow-Pyon Well-Known Member

    Joined:
    Jan 25, 2017
    Messages:
    1,235
    Likes Received:
    176
    Medals:
    Welp, setting the event-item (or maybe event-slot, you'll have to try it) to air should achieve the same effect.
     
  10. Selvati

    Selvati Active Member

    Joined:
    Jun 26, 2017
    Messages:
    190
    Likes Received:
    10
    After a lot of time trying out several things from the docs, which half seem to be broken, I am proud to present the finished product, which only prevents the player from taking the crafting table's result slot item, in these examples below, I had to work around the fact that I couldn't compare a clicked slot type to RESULT, but at the same time not preventing the player from moving an iron axe in his/her inventory while in a workbench.

    Here is an example for any viewers looking to use this system :emoji_slight_smile:), thank you too everyone for your input <3.


    Code (Skript):
    1. # -
    2. # In this example each player will only be able to craft 3 iron axes unless their variable is reset to 0.
    3. # -
    4. # Craft Limit Check
    5. on inventory click:
    6.     if inventory type of player's current inventory is "WORKBENCH":
    7.         if clicked item is iron axe:
    8.             if clicked inventory is not player's inventory:
    9.                 if clicked slot is 0:
    10.                     if {craft.axe.%player%} = 3:
    11.                         cancel event
    12.                         send "You cannot craft any more axes!"
    13.                         stop
    14.                     add 1 to {craft.axe.%player%}
    15.                     send "successfully crafted axe"
    It took me a while but I'm happy that I could solve this issue with a simple work around, now I just can't wait for an addon developer to revive json!
    --- Double Post Merged, Dec 21, 2017, Original Post Date: Dec 21, 2017 ---
    Just sliding onto this post once more, this is also useful if anyone would like to make special crafts that are permission specific, allowing donors/certain ranks to craft special things, the possibilities are endless! Happy Holidays! ♥
    ~Selvati
     
  11. Pikachu

    Supporter Addon Developer

    Joined:
    Jan 25, 2017
    Messages:
    870
    Likes Received:
    139
    Medals:
    I relaly don't get why you aren't just using on craft. Also, json is already a thing in multiple addons.
     
  12. Selvati

    Selvati Active Member

    Joined:
    Jun 26, 2017
    Messages:
    190
    Likes Received:
    10
    I use spigot 1.8.9 please do tell which json addons are working? & also I know this is in a way over complicated but it helps me grow in skript knowledge so I'm happy :]
     
  13. Pikachu

    Supporter Addon Developer

    Joined:
    Jan 25, 2017
    Messages:
    870
    Likes Received:
    139
    Medals:
    What kind of json are we talking? Parsing json? Chat component?
     
  14. Selvati

    Selvati Active Member

    Joined:
    Jun 26, 2017
    Messages:
    190
    Likes Received:
    10
    Chat components, the example that comes to mind is vanilla achievements, you can hover over green text to reveal details.
    --- Double Post Merged, Dec 21, 2017, Original Post Date: Dec 21, 2017 ---
    I’m aware of skjson, but it doesn’t work for my server oddly enough.
     
  15. Pikachu

    Supporter Addon Developer

    Joined:
    Jan 25, 2017
    Messages:
    870
    Likes Received:
    139
    Medals:
    skript-json is not for that. You can use json.sk or vanilla skript on dev29+.
     
  16. Selvati

    Selvati Active Member

    Joined:
    Jun 26, 2017
    Messages:
    190
    Likes Received:
    10
    Alright thanks I’ll look into it
     
Thread Status:
Not open for further replies.

Share This Page

Loading...