25.06.2015, 00:13
This code is terrible. No wonder why your server lags.
Not only to mention about how slow fwrite is compared to MySQL but you also push it out of the limit. You can't just save 50 variables each second and expect your server to have a good performance.
If you're looking to improve this a bit, try to save player stats each 10 minutes and for each player separately. When the player logins to his account set a repeating timer each 10 minutes and do the above code you do. Although this way might not be the best, it's still better then what you're/were going to do.
Not only to mention about how slow fwrite is compared to MySQL but you also push it out of the limit. You can't just save 50 variables each second and expect your server to have a good performance.
If you're looking to improve this a bit, try to save player stats each 10 minutes and for each player separately. When the player logins to his account set a repeating timer each 10 minutes and do the above code you do. Although this way might not be the best, it's still better then what you're/were going to do.