Results 1 to 10 of 69

Thread: Saving a variable client-side (persistently)

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #29
    Private
    Join Date
    Apr 2020
    Posts
    67
    Thanks
    30
    Thanked 14 Times in 13 Posts
    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.
    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();
    }
    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.
    I started reading this thread https://killtube.org/showthread.php?...ll=1#post13719 but i got more confused.


    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;
    }
    How is it supposed to be called in my situation? Any help please??

  2. The Following User Says Thank You to agribilos For This Useful Post:

    kung foo man (31st May 2020)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •