damage22 Posted June 28, 2010 Share Posted June 28, 2010 Hi everybody! I'm trying to figure out the best way to store data about players, for example their stats, car keys, houses etc. The built-in system, as far as i get it, has moved from accounts.xml to internal.db. Developers claim that now it's faster and more reliable, hence xml is slower. Also i've noticed, that all values are stored in the same table, with key and userid fields used to select them. So i suppose it's slower than dedicated tables for each key (or each player?). Basciaclly, i've came up with several ideas: 1) Load XML when resource starts, then use it to get player stats if needed 2) Use setAccountData and getAccountData each time we need something 3) Use SQLite and special tables for stats, vehicle ownership etc., then query if there's something we need 4) Use any of those above to load data on resource start (or player login), then store the info in some global variables (eg arrays, indexed by user id) 5) Same as #4, but use setElementData on player with sync turned off I understand, that with 10 players and 20 accounts all of them will work fine, but i suppose that with increased load some of them will be slower than the others. I also understand, that each method will have different pros and cons in different scenarios. To make this easier, let's say i want to store car keys (and each player can have more than one) and check them everytime player enters\exits\starts the vehicle. Suggestions? Thanks in advance! Link to comment
dzek (varez) Posted June 28, 2010 Share Posted June 28, 2010 SQLite or MySQL. need some effort to implement, but its worth. should be fastest with lot of data Link to comment
damage22 Posted June 28, 2010 Author Share Posted June 28, 2010 Ok, thanks! And what about pre-load vs. ondemand? I mean, if the server has enough free RAM, wouldn't it be easier to load all stats to local variables on resource start? Or it's too much? BTW, isn't xml loaded to memory? Because when i edit xml on running server, ingame contents change only after another xmlLoadFile. Should i load-unload it, or it's ok to keep it in memory? Link to comment
dzek (varez) Posted June 28, 2010 Share Posted June 28, 2010 And what about pre-load vs. ondemand? I mean, if the server has enough free RAM, wouldn't it be easier to load all stats to local variables on resource start? Or it's too much? im programmer, and my experiences are saying: dont keep A LOT of not-needed-at-all data in memory.. BTW, isn't xml loaded to memory? Because when i edit xml on running server, ingame contents change only after another xmlLoadFile. Should i load-unload it, or it's ok to keep it in memory? well, its not like that.. re-reading xml on every (second? or just in "real time") will be just useless. when you are loading xml, you are loading data into something (variables), right? you can modify that data, then save again/discard/whatever. Link to comment
The_Ex Posted June 28, 2010 Share Posted June 28, 2010 im programmer, and my experiences are saying: dont keep A LOT of not-needed-at-all data in memory.. On VPS you might run into CPU bottleneck pretty fast so keeping stuff on RAM for fast access is better. Actually, i would prefer that for most cases because stats are not "not-needed-at-all" because they are regularly updated, but you should load stats for online players only and use queries for offline user stats if needed. That way you won't keep too much on RAM and also speed things up a bit. However, server failure might occur so you have to auto-save stats like every 5-10mins. Link to comment
damage22 Posted June 28, 2010 Author Share Posted June 28, 2010 Thanks! Yeah, that's a good idea. It's always a trade-off between access speed and amount of free memory, but if i have enough free memory, why not use it to lower CPU load? So I'll use cache for online players (even if it will be 250+, as it is planned for MTA 1.1, it's not that much), and query for data on player login. Link to comment
darkdreamingdan Posted June 28, 2010 Share Posted June 28, 2010 Do bear in mind MTA 1.0.4 uses SQlite for it's accounts system. getAccountData and setAccountData should be reliable in that respect. Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now