View Single Post
WAR3DM
Senior Member
Join Date: Mar 2016
Old 09-08-2016 , 04:26   Re: [SQLite] Combining Rows like nVault
Reply With Quote #10

Quote:
Originally Posted by PlayStation View Post
you need to understand, that the lagging comes from querying process during gameplay, which affects fps and if every players queries 500k rows no wonder it lags

if you would separate players for example by nickname you will have 10-30k in each table maybe, also i don't think all players are active, you could speed up your SELECT'ion if you just check which players are active
Yes, I know the lag is from querying 500k rows during gameplay.

Yes, I'm trying to separate rows by Steam_ID. (player_id)



Here is some nVault code that pulls it off
---------------------------------------------------------


Save:
PHP Code:
    formatex(vaultkeycharsmax(vaultkey), "%s-quests"SteamID)
    
    
iPos num_to_str(TotalQuests[id], vaultdatacharsmax(vaultdata))
    
vaultdata[iPos++] = ' '
    
    
for(new iiQuestCounti++) {
        
iPos += formatex(vaultdata[iPos], charsmax(vaultdata) - iPos"%i "iQuestLevel[id][i])
    }
    
nvault_set(gVaultvaultkeyvaultdata
Load:
PHP Code:
    formatex(vaultkeycharsmax(vaultkey), "%s-quests"SteamID
    
    
nvault_get(gVaultvaultkeyvaultdatacharsmax(vaultdata))
    
    
argbreak(vaultdataszValcharsmax(szVal), vaultdatacharsmax(vaultdata ))
    
    
TotalQuests[id] = str_to_num(szVal)
    
    for(new 
iiQuestCounti++) {
        
argbreak(vaultdataszVal charsmax(szVal) , vaultdata charsmax(vaultdata)) 
        
iQuestLevel[id][i] = str_to_num(szVal)
    } 


Now compare it to my current SQL
---------------------------------------------------------

Save:
PHP Code:
// Now we need to save the skill levels!
for ( new iSkillID 0iSkillID MAX_SKILLSiSkillID++ )
{
    
formatexszQuery511"REPLACE INTO `skills` ( `player_id` , `skill_id` , `skill_level` ) VALUES ( '%d', '%d', '%d' );"iUniqueIDiSkillIDp_data_skill[id][iSkillID] );
    
query SQL_PrepareQueryg_DBConnszQuery );

Load:
PHP Code:
// Select the right Table
    
formatszQuerycharsmaxszQuery ), "SELECT `skill_id`, `skill_level` FROM `skills` WHERE ( `player_id` = '%d' );"p_data[id][PLAYER_UNIQUEID] );
    
query SQL_PrepareQueryg_DBConnszQuery );

// While we have a result!
    
new iSkillID 0;
    while ( 
SQL_MoreResultsquery ) )
    {
        
iSkillID SQL_ReadResultquery);
        
p_data_skill[id][iSkillID] = SQL_ReadResultquery);

        
SQL_NextRowquery );
    } 

Last edited by WAR3DM; 09-08-2016 at 04:36.
WAR3DM is offline