Yml files with keys

  • 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 community!

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

  • LOOKING FOR A VERSION OF SKRIPT?

    You can always check out skUnity Downloads for downloads and any other information about Skript!

Status
Not open for further replies.

Nckyi

Member
Mar 3, 2017
2
0
1
I need a skript that would keep randomly generated keys (that can be obtained on random generator websites) and that would be kept inside of YML files. When player would use the command
/redeem i.e /redeem ADWAD098ODA982;
It would remove the used key from the correct yml and give the player the reward from said key.

I can't find a way to actually make skript read the yml to find the said key and then delete it.
The reason it needs to be deleted is so it can only be used by one player.
 
code_language.skript:
command /generatecode:
  trigger:
    if player is op:
      set {_code} to a random 10 char string from `a-zA-Z0-9`
      add "%{_code}%" to yaml list "ActiveCodes" from file "plugins/YourFolder/YourFile.yml"
      send "Code Generated: %{_code}%" to player

command /redeem [<string>]:
  trigger:
    if arg-1 is set:
      set {_list::} to yaml list "ActiveCodes" from file "plugins/YourFolder/YourFile.yml"
      loop {_list::*}:
        if arg-1 is "%loop-value%":
          remove loop-value from yaml list "ActiveCodes" from file "plugins/YourFolder/YourFile.yml"
          send "Code Successfully redeemed" to player
          stop
      send "Invalid Code" to player
    else:
      send "You did not provide a code to redeem" to player
I'm not sure if something like this is what you need, but this should get what you need done, it doesn't use a random generator website however as you can randomly generate a string with skript itself
 
Status
Not open for further replies.