UUID Storage

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

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

Inferno

Member
Feb 2, 2017
20
0
0
24
code_language.skript:
on join:
    if file "/plugins/Skript/scripts/UUID Storage.yml" exists:
        set {_fileContents::*} to file contents of "/plugins/Skript/scripts/UUID Storage.yml"
    if file "/plugins/Skript/scripts/UUID Storage.yml" doesn't exist:
        create file "/plugins/Skript/scripts/UUID Storage.yml"
        write "%player% = %player's uuid%" at line 1 to file "/plugins/Skript/scripts/UUID Storage.yml"
        stop trigger
    else if {_fileContents::*} does not contain "%player% = %player's uuid%":
        set {_lines} to line count of file "/plugins/Skript/scripts/UUID Storage.yml"
        write "%player% = %player's uuid%" at line ("%{_lines} + 1%" parsed as integer) to file "/plugins/Skript/scripts/UUID Storage.yml"
        stop trigger
#   Else here
If I place an else after the else if statement it will send that. Correct me if I am wrong, but lines 4-11 show that if the file does not exist, create the file and write the players name = the player's UUID then stop, but if the file does exist and players name = the player's UUID has not been written, write the line on the next open spot. Therefore it's pretty much 'if file "/plugins/Skript/scripts/UUID Storage.yml" doesn't exist:' and 'if file "/plugins/Skript/scripts/UUID Storage.yml" exists:'. How can it exist but not exist at the same time? And my UUID is not there, so it should be running the else if.
 
Code:
(file|folder) [in] %text% exists
(file|folder) [in] %text% (does not|doesn't|is not|isn't) exists
Code:
If file "/plugins/Skripts/scripts/UUID Storage.yml" does not exist:
should work.
 
Your checking system for if the file contains the uuid is wrong. You haven't added a condition in the first place to check if the uuid is in the list variable, you've just added an "else if" which refers to the wrong condition.

Also, it is way easier to use YML instead of txt.

Code:
Set yaml value "%player%" in file "FILE PATH" to "%player's uuid%"
[doublepost=1487449248,1487449004][/doublepost]Another thing, why do you need to store your UUIDs? Whenever you need to get any UUID, just use
Code:
%player's uuid%
Or
Code:
set {_player} to arg-1
Set {_uuid} to ({_player} parsed as offlineplayer)'s uuid
 
Your checking system for if the file contains the uuid is wrong. You haven't added a condition in the first place to check if the uuid is in the list variable, you've just added an "else if" which refers to the wrong condition.

Also, it is way easier to use YML instead of txt.

Code:
Set yaml value "%player%" in file "FILE PATH" to "%player's uuid%"
[doublepost=1487449248,1487449004][/doublepost]Another thing, why do you need to store your UUIDs? Whenever you need to get any UUID, just use
Code:
%player's uuid%
Or
Code:
set {_player} to arg-1
Set {_uuid} to ({_player} parsed as offlineplayer)'s uuid
I'll rewrite it using YML, but I don't think that will fix the issue. But you say that the 'else if' refers to the wrong condition and such? How would I do this?

And to answer your question, in a few different scripts I use(d) this script to loop all player's UUIDs who have joined.
 
I'll rewrite it using YML, but I don't think that will fix the issue. But you say that the 'else if' refers to the wrong condition and such? How would I do this?

And to answer your question, in a few different scripts I use(d) this script to loop all player's UUIDs who have joined.
You've made it so that, if the file doesn't exist, it will create it then write it. However, if the file exists it will still write it in... You haven't added the check for if the uuid already exists in the file. All you've added is an else if statement to that, which skript thinks is pointing towards one of the other if conditions.
 
Status
Not open for further replies.