YAML write and read help

  • 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.

infered5

New Member
Mar 12, 2017
5
0
1
Skript 2.2-Fixes-V9b
SkQuery 3.21.4
SkUtilities 0.8.8
skRayFall 1.9.2
Minecraft 1.8.8 with ViaVersion up to 1.11.2

I'm trying to make a system where players can only change their nicknames a few times, with the ability to add the amount of times they can change it. I'd like to make a YAML file, with a command that adds the player's UUID and the amount of nicks they have left.

What I'd like is something like:

Code:
players:
  uuid:
  - 1
  uuid:
  - 3
  uuid:
  - 5
and so on and so forth. I can easily read YAMLs but I cannot figure out how to generate and write to them. So far I have
Code:
set {_guns::common::*} to yml list "guns.common" of file "plugins/Skript/Cryptarch/droptable.yml"
from my other large Skript that reads from a droptable, so I can salvage that code easily enough. I have no idea how I'm going to write to them, nothing works right.

Code:
command /addnick <player>:
    permission: destiny.nickname.add
    trigger:
        set {_uuid} to player's UUID
        set {_1} to 1
        message "%{_uuid}%"
        if yaml value "player.%arg 1%" of file "/plugins/Destiny/test.yml" exists:
            send "Player already exists! Adding use!" to the console
            add "%{_1}%" to yaml list "player.%arg 1%.use" of file "/plugins/Destiny/test.yml"
        set {_uses::*} to yaml list "player.%arg 1%.use" of file "/plugins/Destiny/test.yml"
        message "%{_uses::*}%"
Edit: Now I have the ability to write to a YAML, but the YAML generated is as follows:
Code:
player:
  infered5:
    use:
    - '1'
    - '1'
    - '1'
Is there a way to change this so it's like this:
Code:
player:
  infered5:
    use:
    - '3'
 
Last edited:
Status
Not open for further replies.