Help with Skript Variables and yaml files.

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

Error101

Member
Jan 15, 2024
1
0
1
23
I need help with saving and loading these variables. Basicly I want kills and deaths to be set to 0 when the player first joins the server in a yaml of their uuid. then I want the yaml to update when the player dies or gets a kill. then I want the scoreboard to update based on the yaml.

Some code left out for privacy purposes.

Code:
on first join:
    set {_uuid} to {uuid::%player%}
    set {_yamlPath} to "plugins/Skript/player-data/%{_uuid}%.yml"
    set {_defaultStats} to {"kills":: 0, "deaths":: 0}
   
    if file {_yamlPath} does not exist:
        save yaml {_defaultStats} to {_yamlPath}


on join:
    load yaml "plugins/Skript/player-data/%{uuid of player}%.yml" as "data-%uuid of player%"
    set yaml value "last-login" in "data-%uuid of player%" to now

on quit:
    save yaml "data-%uuid of player%"
    unload "data-%uuid of player%"

every 3 seconds:
    loop all players:
        set {_online} to number of all players
        wipe loop-player's sidebar
        set name of sidebar of loop-player to "{@server}"
        set score "&7&m-------------------" in sidebar of loop-player to 8
        set score "&c&lPLAYER&7: &a&l%loop-player%" in sidebar of loop-player to 7
        set score "&4&lKills&f: &a%{data-%uuid of loop-player%::kills::0}%" in sidebar of loop-player to 6
        set score "&4&lDeaths&f: &a%{data-%uuid of loop-player%::deaths::0}%" in sidebar of loop-player to 5
        set score "&a&lPing&7: &a%loop-player's ping%" in sidebar of loop-player to 4
        set score "&6&lONLINE PLAYERS&7: &a%{_online}%" in sidebar of loop-player to 3
        set score "&7&m-------------------" in sidebar of loop-player to 2
        set score " &f&l- &8{@website}" in sidebar of loop-player to 1

on death:
    victim is a player:
        attacker is a player:
            add 1 to {data-%uuid of attacker%::kills}
            add 1 to {data-%uuid of victim%::deaths}
            set {_victimUUID} to victim's uuid
            update yaml value "deaths" in "plugins/Skript/player-data/%{_victimUUID}%.yml" to {data-%uuid of victim%::deaths}
            update yaml value "kills" in "plugins/Skript/player-data/%{uuid of attacker}%.yml" to {data-%uuid of attacker%::kills}

every {@update} seconds:
  loop all players:
    set {_online} to number of all players
    wipe loop-player's sidebar
    set name of sidebar of loop-player to "{@server}"
    set score "&7&m-------------------" in sidebar of loop-player to 13
    set score "&c&lPLAYER&7&f: &a&l%loop-player%" in sidebar of loop-player to 12
    set score "&4&lKills&f: &a%{data-%uuid of loop-player%::kills::0}%" in sidebar of loop-player to 11
    set score "&4&lDeaths&f: &a%{data-%uuid of loop-player%::deaths::0}%" in sidebar of loop-player to 10
    set score "&a&lPing&7&f: &a%loop-player's ping%" in sidebar of loop-player to 9
    set score "&6&lONLINE PLAYERS&7&f: &a%{_online}%" in sidebar of loop-player to 8

Errors:

Line 12- cant understand condition save yaml {_defaultStats} to {_yamlPath}
Line 42 - cant understand condition update yaml value "deaths" in "plugins/Skript/player-data/%{_victimUUID}%.yml" to {data-%uuid of victim%::deaths}
Line 43- update yaml value "kills" in "plugins/Skript/player-data/%{uuid of attacker}%.yml" to {data-%uuid of attacker%::kills}

Thanks in advance :emoji_slight_smile:
 
Last edited by a moderator:
Skript doesn't support YAML files natively. You'll need an addon to do this.