Raised This Month: $51 Target: $400
 12% 

Solved Loop order


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
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
 



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 21:24.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode