Thread: [Solved] Loop order
View Single Post
Clauu
Senior Member
Join Date: Feb 2008
Location: RO
Old 01-15-2018 , 13:58   Re: Loop order
Reply With Quote #11

Update your code to something like this, with removing g_iItems from global scope and add parse condition to be sure that all fields are parsed and stored into array:
PHP Code:
ReadFile( )
{
    
ArrayClearg_aDatabase );

    new 
g_iItemsPlayerData ] );

    new 
szConfigs32 ], szFormat64 ], szPlayerData512 ];
    
get_configsdirszConfigscharsmaxszConfigs ) );
    
    
formatexszFormatcharsmaxszFormat ), "%s/%s"szConfigsg_szFile );
    
    new 
iFile fopenszFormat"rt" );
    
    if( 
iFile )
    {
        while( ! 
feofiFile ) )
        {    
            
fgetsiFileszPlayerDatacharsmaxszPlayerData ) );
            
trimszPlayerData );
            
            if( 
szPlayerData] == ';' || strlen(szPlayerData) < 10 || ( szPlayerData] == '/' && szPlayerData] == '/' ) )
            continue;
            
            if(
parseszPlayerDatag_iItems[Player_Name], charsmaxg_iItems[Player_Name] ), g_iItems[Player_Password], charsmaxg_iItems[Player_Password]), g_iItems[Player_AccessFlags], charsmaxg_iItems[Player_AccessFlags] ), g_iItems[Player_Prefix], charsmaxg_iItems[Player_Prefix] ) ) < 4)
             continue;
            
            
ArrayPushArrayg_aDatabaseg_iItems );
        }
        
fcloseiFile );
    }

After that you will have all data stored in array g_aDatabase on wich you will be later iterate read etc.
On the next ReadFile function call, g_aDatabase array will be emptied and filled with new data from file.
Clauu is offline