I tested the mysql functions on my server. Although it loads and saves the data fine and showing properly on the custom hud it really starts to lag the game if there are more than 10 players.
The main suspect is this function. I know it is not optimized because it write all the player stats every time it is called.
It is called several times by every player like on every kill ,death etc. So one solution to make it more efficient would be to make it update one stat at a time and call it like updatestats(stat). I don't know if it would make a big difference so i decided to use asyncronous mysql queries since they are better.Code:updatestats() { result = [[level.mysql_wrapper]]("SELECT * FROM player_information WHERE login = '" + self.izno["login"] + "'", true); if(isdefined(result)) { row = mysql_fetch_row(result); if(isdefined(row)) { for(i=0;i<level.stats.size;i++) { [[level.mysql_wrapper]]("UPDATE player_information set " + level.stats[i] +" = "+self.stats[level.stats[i]]+" WHERE login = '" + self.izno["login"] + "'",false); } [[level.mysql_wrapper]]("UPDATE player_information set playername = '"+self.name+"' WHERE login = '" + self.izno["login"] + "'",false); } mysql_free_result(result); } self notify("update_playerhud_score"); self maps\mp\gametypes\_myhud::updatePlayerScoreHUD(); }
I started reading this thread https://killtube.org/showthread.php?...ll=1#post13719 but i got more confused.
How is it supposed to be called in my situation? Any help please??Code:asyncQuery(query, function, args) { id = mysql_async_createQuery(query); task = spawnstruct(); task.query = query; task.invoker = self; task.function = function; task.args = args; level.JH_mysqlAsync["" + id] = task; }



Reply With Quote