Solved How to Go About Saving Data to a .txt File?

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

Anonymous

Member
Jan 27, 2017
15
0
0
22
I don't know if you can but my friend told me it's possible, I'd have no idea where to start but how would it work?
 
I don't know if you can but my friend told me it's possible, I'd have no idea where to start but how would it work?
Before making a new thread, please be sure you have used all the options available to you. By simply searching "file" in the docs, you will find several solutions.
 
Before making a new thread, please be sure you have used all the options available to you. By simply searching "file" in the docs, you will find several solutions.
I didn't think about using "file" as it, thanks I'll go look now. But for the record I did search up .txt, text document, txt ect.
 
I didn't think about using "file" as it, thanks I'll go look now. But for the record I did search up .txt, text document, txt ect.
You can easily write text to ANY type of file. However, for saving data, it's much better to use YML or a list variable ("{yourvariable::whatever}").
 
I've saved it to the text file now,
code_language.skript:
on join:
  if {iplogs::*} does not contain "%player% - %player's IP%":
    add "%player% - %player's IP%" to {iplogs::*}
    write "%player%'s IP is %player's IP%." to "plugins/iplogs.txt"
Anyone know how to make each time it logs write it on a new line?
 
you're completely wrong there, the YML files aren't for saving data, they are for configuration files, if you want to save data use JSON, CSV or as the OP wants, a TXT file.
A lot of plugins use YML to save all sorts of data. It's the most friendly way (apart from variables) of saving things to a file which is why i suggested it.
 
A lot of plugins use YML to save all sorts of data. It's the most friendly way (apart from variables) of saving things to a file which is why i suggested it.
For a simple little list I'm using to store IPs and draw them for IP banning and such it's the most effective and simplistic way I can go using a .txt file, but thanks for the suggestion.
 
To the OP's question, using skUtilities (also, why you save it in a file and in a variable at the same time):
code_language.skript:
write "%player%'s IP is %player's ip%." at line (file "plugins/iplogs.txt"'s line count + 1) to file "plugins/iplogs.txt"

A lot of plugins use YML to save all sorts of data. It's the most friendly way (apart from variables) of saving things to a file which is why i suggested it.
yeah, it's friendly but but it's more slow when the file is more bigger, that's why I don't recommend YML.
 
Why are you using a txt file when you can just use a variable?

Set {IPs::%player%} to player's ip
To have a saved copy in the files? I already have it in a variable.
To the OP's question, using skUtilities (also, why you save it in a file and in a variable at the same time):
code_language.skript:
write "%player%'s IP is %player's ip%." at line (file "plugins/iplogs.txt"'s line count + 1) to file "plugins/iplogs.txt"


yeah, it's friendly but but it's more slow when the file is more bigger, that's why I don't recommend YML.
Thank you, I'll try it now.
[doublepost=1485635714,1485635247][/doublepost]
To the OP's question, using skUtilities (also, why you save it in a file and in a variable at the same time):
code_language.skript:
write "%player%'s IP is %player's ip%." at line (file "plugins/iplogs.txt"'s line count + 1) to file "plugins/iplogs.txt"
Edit: Found it, just had to use my brain and search the new forums.. lol


yeah, it's friendly but but it's more slow when the file is more bigger, that's why I don't recommend YML.
Happen to have a DL link for SkUtilities 1.8? All I can find is 1.9 and SkUnity's link isn't currently working.
[doublepost=1485635873][/doublepost]
To have a saved copy in the files? I already have it in a variable.

Thank you, I'll try it now.
[doublepost=1485635714,1485635247][/doublepost]
Happen to have a DL link for SkUtilities 1.8? All I can find is 1.9 and SkUnity's link isn't currently working.
Edit: used my brain a bit and found it, lol. Sorry to bother.
 
Status
Not open for further replies.