SQL is fun, it’s FAST ( Google uses a modified version of MySQL with the SQL language to power it’s search engine ), it’s customizable, you can link tables, etc. It’s an incredibly efficient way to store data!
Remember, FILE IO ( Input/Output) is one of the most expensive things you can do, so I’d really recommend learning SQL before setting up a flatfile system and having to redo it down the road. We’ll be more than happy to assist you as long as you’re willing to learn.
The examples I gave were simple selects, the last one linked 2 tables together to avoid doing a query to get data, and then another query to finish getting data from another table. You can chain as many as you want together essentially. That’s why I said you want to get away from STEAMID, has a primary account table hold the steamid and unique id, and other information which is then bound to a unique, primary, auto_increment id which can then be mapped across ALL other tables. You join on other tables from the account_table. userid ON other_table.userid, etc etc, and you querty the WHERE account_table.steamid = “blah” that way you have 1 way in to the entire structure, and a nice way to link across. You could use STEAMID for everything, but the issue as I said just 1 user with 1000 entries is 15kb. You have thousands of users and just steamid for EVERYTHING really adds up.
Design everything on paper first, and design a database wrapper / helper functions to assist with backwards compatibility as said, because it is a 3rd party module. If Garry updates the game, they may go down, if one is up before the other you should have some solution created that you just drop the DLLs in, and it works. If you follow that logic I told you for on connect, if fail include and try connecting using other module. I think there is more than 2 out there, chain even more together…
It’s just so robust, if you’re willing to learn… I provided you with 1 simple helper function which provides the cross-compatibility ( SUPER HELPFUL / USEFUL ), so when you design your queries, use that so that if one goes down, that part is set, then you just have to handle connecting.
BASIC FORMAT IS:
Option A) SELECT column1, column2 FROM table
Option B) SELECT * FROM table // Selects ALL, so when you output remember it will be in order of how the structure is set up, if you alter that then you have to change your code; which is why I recommend always using option A instead of *
Using Option A with conditions: SELECT column1, column2 FROM table WHERE steamid = ‘BLAH’ LIMIT 1 // limits to 1 result, on that steam id.
Now, when you INSERT INTO, or UPDATE your tables, make sure you ESCAPE your strings. use http://wiki.garrysmod.com/page/Global/SQLStr to escape them, otherwise people can INJECT data by changing their name, spoofing steam, or doing other things which can WIPE your entire database.
I just found this which you can learn with, it’s interactive: http://www.sqlcourse.com/index.html