YML 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 comminuty!

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

Nckyi

Member
Mar 3, 2017
2
0
1
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:
Reward1:
Keys:
ab252cefghijkl
aw23423awdawd
awdwafaf23423aga
Reward2:
Keys:
ada34535wdawd
awd23423aawdd


Ideas for commands:
/key add (key) (reward)
/redeem (key)
Ideas for permissions:
randomname.addkey
randomname.redeem
When I'd like it by: A reasonable time
 
i would doing the jobs. but i'm worried now...

I need a skript that would keep randomly generated keys


Ideas for commands:
/key add (key) (reward)

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



#Edit

This is what i currently got...

code_language.skript:
command /key [<text>] [<text>]:
    trigger:
        if arg-1 is not set:
            send "Please enter which section should there?"
            stop
        if arg-2 is set:
            if player's tool is air:
                send "Please hold some items. that you wan't give a rewards items."
                stop
            set yaml value "Key.%arg-1%.Rewards" from file "plugins/Code/code.yml" to "%player's tool%"
            send "Rewards for %arg-1% set up!"
            stop
        set {_a::*} to yaml nodes "Key.%arg-1%" from file "plugins/Code/code.yml"
        loop {_a::*}:
            if "%loop-value%" is "Rewards":
                set {_a} to true
                stop loop
        if {_a} is not set:
            send "Please remain, to give a some items rewards with ""/key %arg-1% Rewards"", you need just hold some items in hands!"           
        set {_code} to random 8 char string from `a-zA-Z0-9`
        set {_B} to yaml value "Key.%arg-1%.%{_code}%" from file "plugins/Code/code.yml"
        if {_B} is not set:
            set yaml value "Key.%arg-1%.%{_code}%" from file "plugins/Code/code.yml" to "false"
            send "Code Generated in section %arg-1%: %{_code}%"
        else:
            send "Sorry. please enter again code. Because its found that code already exists."
        
command /redeem [<text>]:
    trigger:
        if arg-1 is not set:
            send "Enter code."
            stop
        set {_Bla::*} to yaml nodes "Key" from file "plugins/Code/code.yml"
        loop {_Bla::*}:
            set {_a} to yaml value "Key.%loop-value%.%arg-1%" from file "plugins/Code/code.yml"
            if {_a} is "false":
                set {_b} to "%loop-value%"
                stop loop
        if {_a} is "false":
            set {_i} to yaml value "Key.%{_b}%.Rewards" from file "plugins/Code/code.yml"
            if {_i} is not set:
                send "Sorry. please contact admins. There is ""Rewards"" missing."
                stop
            set yaml value "Key.%{_b}%.%arg-1%" from file "plugins/Code/code.yml" to "%player%"
            give player ("%{_i}%" parsed as item)
            send "you reedem a code. you got %{_i}%"
        else if {_a} is not set:
            send "Are you sure, you enter a right code?"
        else:
            send "This is already reedem."
 
Last edited by a moderator: