Do you think I could just leave this part blank and it'd be okay? We're just going to replace the whole thing with a header image anyway, right?
You are not logged in.
Pages: 1
Hi there guys.
So just a month ago I think I started with making bots. I used tutorials for saving wins etc. Now I'm using the .ini files to save data.
Now here come's my problem. I feel like this is not the best way to save data. It's hard to loop through etc.
What method would you guys recommend for me.
As I'm still learning every day new things in C# something that would be a bit user friendly would be nice
(Btw want to have the data saved on my own pc. Just in case someone comes with a server method.)
It's meant to save user data for my bot games.
Ingame: marten22 My steam: MartenM
Offline
I used just regular text files.
thanks zoey aaaaaaaaaaaand thanks latif for the avatar
Offline
Use XML or text documents or why not, MySQL database.
Offline
^Do you have a suggestion on a tutorial for setting up SQL databases? I had an SQLite database (cuz idk why) and that was a pain... the updates were always the wrong version for the .NET framework... and I updated from NuGet vs. web download ugh all around.
If you want "user friendly," then the easiest thing you can do is a straight-to-textfile approach. Then you can see if your function is outputting right, etc. However, the next best thing would prolly be cap's SQL suggestion. Provided a good UI, all you'd need to figure out is the actual programming quirks involved.
But straight easiest, user-friendly approach is definitely text.
I used binary writer/reader back in the day. You can't really read those with your eyes... but they worked well enough once I figured it out.
Offline
My vote goes for text files.
Use StringBuilder and the File class for that.
Offline
Why does everybody suggest MySQL? Isn't it a hassle? I tried to google some things about it and I couldn't find anything that would help me set one up - just to see what it would be like to have one
thanks zoey aaaaaaaaaaaand thanks latif for the avatar
Offline
Well, I like this discussion
stackoverflow look out kiddos
idk what to make of it. saving a file seems to make sense... but I suppose if we actually got to a lot of people, loading all 2000 (wishful thinking) players' data isn't as reasonable (on the RAM or whatever) as the 30 active, present folk.
For the most part, I probably had my DB poorly configured, because it always took too long to make a search, much longer than if I just loaded the data into memory.
Offline
PROTOBUF.
I have never thought of programming for reputation and honor. What I have in my heart must come out. That is the reason why I code.
Offline
It's hard to loop through etc.
If you're not already using the 'File.ReadAllLines' method in System.IO, which reads all the lines into a string array, you should. It makes reading from the file incredibly easy, and from there you can loop through the array and split each line or whatever.
If you really think you have enough data to justify using a DB, I recommend SQL Compact Edition, which is well supported by VS and can store all your data in a single datatable (.sdf) file.
One bot to rule them all, one bot to find them. One bot to bring them all... and with this cliché blind them.
Offline
Couple suggestions also listing previous suggestions I find good:
Plain text file (I'd say is hardest as you have to give your own context to everything).
CSV file (Usually what people do when they write to plain text).
XML file (you have to make your objects serializable though, not hard, but you'd have to make a couple googles in how to do this. + side is you can save and load object directly through a single simple method you rip off the internet).
JSON file (basically same concept as XML. Makes your files some smaller, but for some people it's a bit harder to understand, again).
Database (I'd say Ms/Sql, I think visual studio can automatically create a local mssql database in your project, otherwise it's another sql language. Problem is you'd have to learn SQL and would still have to format it back into your own objects, but it's by far the strongest method).
Offline
What i would always do(and did up until i became inactive on ee) was i would have a function to save each persons data. So let's say that you were making an rpg and wanted to save a person's HP, i would have a function just dedicated to HP, kinda like i had one for wins. I would have a function that would check wins and one that would add wins. Like for the digbot i had, i had so many functions that it made it easy when i was making aspects of the game, but it was a ton of code. I came up with a more efficient way later, but i would start there to make it easy.
If you just want to save data right then and there, you can make a dictionary with the key being the userid and the value being another dictionary, the key of that dictionary could be the thing you're searching for, for example, HP, you type the string 'HP' and that person's HP would then come up. You can save it when they leave(which isn't the best idea if your bot crashes a lot). But that's another approach you could take.
If you would like me to make a bot for you, go here.
Offline
What i would always do(and did up until i became inactive on ee) was i would have a function to save each persons data. So let's say that you were making an rpg and wanted to save a person's HP, i would have a function just dedicated to HP, kinda like i had one for wins. I would have a function that would check wins and one that would add wins. Like for the digbot i had, i had so many functions that it made it easy when i was making aspects of the game, but it was a ton of code. I came up with a more efficient way later, but i would start there to make it easy.
If you just want to save data right then and there, you can make a dictionary with the key being the userid and the value being another dictionary, the key of that dictionary could be the thing you're searching for, for example, HP, you type the string 'HP' and that person's HP would then come up. You can save it when they leave(which isn't the best idea if your bot crashes a lot). But that's another approach you could take.
It's kinda dirty though how you have to push all stats of the player through when you only want his HP. Best you just use public fields, with optionally a private set.
Offline
^ so player["hummerz5"]["HP"]?
I mean, a dictionary probably is overhead compared to a (public field?) but it's pretty easy to manage, too...
except for when you go making new attributes that don't have values... then the whole NotFoundException or whatever
yeah carry on
Offline
^ so player["hummerz5"]["HP"]?
I mean, a dictionary probably is overhead compared to a (public field?) but it's pretty easy to manage, too...
except for when you go making new attributes that don't have values... then the whole NotFoundException or whateveryeah carry on
Fields are basically variables, haven't found the exact differences though. But you'd declare them in the head of your class (so not in a method), and this would be an example:
public int HP { get; private set; } // note no ; at the end
The { get; private set; } are automatic properties, meaning the get (getting the value) is public, and the set (setting the value) is private.
// You can do:
int playerHP = player.HP
// But can't do:
player.HP = 5
You can only set the HP value from within the Player class/object itself.
And you don't take half an hour making all those get set methods.
Note: You CAN also just make a public variable, but this is generally bad practice.
EDIT: You can also do some other stuff with the get and set, but won't go into detail with them.
Offline
I would likely use a NoSQL database, probably MongoDB or similar.
*u stinky*
Offline
i said the complete wrong thing, what i usually do is make a dictionary with just a userid and a playerclass. I do sometimes use nested dictionaries but not for player information, i used it for something that really isn't required here. But just making a single player class and loading it when a player joins and saving when a player leaves would work just fine. As long as your bot is simple enough to not crash all the time, and if it does crash, you can save your data every 5 minutes or so(a lot better than live).
If you would like me to make a bot for you, go here.
Offline
And you don't take half an hour making all those get set methods.
public int HP { get; private set; }
Yeah, instead you do get PRIVATE set methods
thanks zoey aaaaaaaaaaaand thanks latif for the avatar
Offline
i said the complete wrong thing, what i usually do is make a dictionary with just a userid and a playerclass. I do sometimes use nested dictionaries but not for player information, i used it for something that really isn't required here. But just making a single player class and loading it when a player joins and saving when a player leaves would work just fine. As long as your bot is simple enough to not crash all the time, and if it does crash, you can save your data every 5 minutes or so(a lot better than live).
or, with the crashing:
add a soft landing... catch the error, save the data, then throw it for the IDE?
Offline
den3107 wrote:And you don't take half an hour making all those get set methods.
den3107 wrote:public int HP { get; private set; }
Yeah, instead you do get PRIVATE set methods
You can always remove the private and get a public set method, really that hard to figure out? Can also make the get private, but I just added the private to show it's possible.
Offline
Jabatheblob1 wrote:i said the complete wrong thing, what i usually do is make a dictionary with just a userid and a playerclass. I do sometimes use nested dictionaries but not for player information, i used it for something that really isn't required here. But just making a single player class and loading it when a player joins and saving when a player leaves would work just fine. As long as your bot is simple enough to not crash all the time, and if it does crash, you can save your data every 5 minutes or so(a lot better than live).
or, with the crashing:
add a soft landing... catch the error, save the data, then throw it for the IDE?
Yeah you can do that, i'm just suggesting simplified answers given he's asking how to save data. I don't know if that's too far for him or not.
If you would like me to make a bot for you, go here.
Offline
Pages: 1
[ Started around 1732431682.0823 - Generated in 0.182 seconds, 14 queries executed - Memory usage: 1.7 MiB (Peak: 1.93 MiB) ]