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!

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

YML Keys

Discussion in 'Requests' started by Nckyi, Apr 5, 2017.

  1. Nckyi

    Nckyi Member

    Mar 3, 2017
    Likes Received:
    Category: YML

    Suggested name: None

    What I want:
    I need a skript that would keep randomly generated keys (that can be obtained on random generator websites) inside of a YML file. When player would use the command /redeem
    i.e /redeem ADWAD098ODA982;
    It would remove the used key from the yml and give the player the reward from said key.

    The yml file would look something like this:

    Ideas for commands:
    /key add (key) (reward)
    /redeem (key)
    Ideas for permissions:
    When I'd like it by: A reasonable time
  2. ShaneBee

    Supporter + Addon Developer

    Sep 7, 2017
    Likes Received:
    i would doing the jobs. but i'm worried now...

    uhm? Random generator? Add key? Uhm... wut?!


    This is what i currently got...

    Code (Skript):
    1. command /key [<text>] [<text>]:
    2.     trigger:
    3.         if arg-1 is not set:
    4.             send "Please enter which section should there?"
    5.             stop
    6.         if arg-2 is set:
    7.             if player's tool is air:
    8.                 send "Please hold some items. that you wan't give a rewards items."
    9.                 stop
    10.             set yaml value "Key.%arg-1%.Rewards" from file "plugins/Code/code.yml" to "%player's tool%"
    11.             send "Rewards for %arg-1% set up!"
    12.             stop
    13.         set {_a::*} to yaml nodes "Key.%arg-1%" from file "plugins/Code/code.yml"
    14.         loop {_a::*}:
    15.             if "%loop-value%" is "Rewards":
    16.                 set {_a} to true
    17.                 stop loop
    18.         if {_a} is not set:
    19.             send "Please remain, to give a some items rewards with ""/key %arg-1% Rewards"", you need just hold some items in hands!"          
    20.         set {_code} to random 8 char string from `a-zA-Z0-9`
    21.         set {_B} to yaml value "Key.%arg-1%.%{_code}%" from file "plugins/Code/code.yml"
    22.         if {_B} is not set:
    23.             set yaml value "Key.%arg-1%.%{_code}%" from file "plugins/Code/code.yml" to "false"
    24.             send "Code Generated in section %arg-1%: %{_code}%"
    25.         else:
    26.             send "Sorry. please enter again code. Because its found that code already exists."
    28. command /redeem [<text>]:
    29.     trigger:
    30.         if arg-1 is not set:
    31.             send "Enter code."
    32.             stop
    33.         set {_Bla::*} to yaml nodes "Key" from file "plugins/Code/code.yml"
    34.         loop {_Bla::*}:
    35.             set {_a} to yaml value "Key.%loop-value%.%arg-1%" from file "plugins/Code/code.yml"
    36.             if {_a} is "false":
    37.                 set {_b} to "%loop-value%"
    38.                 stop loop
    39.         if {_a} is "false":
    40.             set {_i} to yaml value "Key.%{_b}%.Rewards" from file "plugins/Code/code.yml"
    41.             if {_i} is not set:
    42.                 send "Sorry. please contact admins. There is ""Rewards"" missing."
    43.                 stop
    44.             set yaml value "Key.%{_b}%.%arg-1%" from file "plugins/Code/code.yml" to "%player%"
    45.             give player ("%{_i}%" parsed as item)
    46.             send "you reedem a code. you got %{_i}%"
    47.         else if {_a} is not set:
    48.             send "Are you sure, you enter a right code?"
    49.         else:
    50.             send "This is already reedem."
    #2 ShaneBee, Apr 23, 2017
    Last edited by a moderator: Apr 23, 2017

Share This Page