- Home /
Best way to manage stats in a text file
I'm thinking of reading user stats from a text file, line at a time. My questions:
Saving data line-by-line. I can get the string, how do I just add a line?
What do you say is the best (most efficient way) to save the user's stats (weapons, points) I'm thinking of this:
If my text file looks like this:
Username1;Password1;2.3.5.3.4.5.7.6.4/5863465/68
Username2;Password2;2.3.5.7.6.8.3.9.6.8.3/28450/01 etc.
The username and password are separated with String.Split(";");
It's also separated by the slashes and decimals, so they're all separate.
My idea is that every separated blank represents the weapon that they have per class (like 2 is sub-machine 2, etc). Then the /28450 is their points (except for the slash) and the other is their level. Maybe even upgrades/perks/etc should be included. What do you think? Remember it's going to be a string so it needs to be able to read it as text. You have a better and more efficient way?
Okay I guess none of you really answered my question; I'm just simply asking if anyone has a better method to store a string of text. I'm not asking how, I'm asking if you have a concept for a better way to read/write a series of numbers in a small format but easy to use. It's not really that hard of a question
If a string of data in a text file is not the only option you are considering then have you considered X$$anonymous$$L for storing your data? Saving and Loading Data: XmlSerializer
Answer by Graham-Dunnett · Jul 04, 2014 at 12:32 PM
Use PlayerPrefs.
Thanks, but I know about PlayerPrefs. That's not what I want to use. I guess I should've mentioned that.
Answer by kannan21 · Jul 04, 2014 at 12:35 PM
Create a class called playerstats and then save all the data in that class, then save all the classes in a list and then serialize that list. I use this method to serialize my data.
http://msdn.microsoft.com/en-us/library/4abbf6k0(v=vs.110).aspx