Thread: [Solved] Duplicated reading?
View Single Post
Author Message
edon1337
Penguin Enthusiast
Join Date: Jun 2016
Location: Macedonia
Old 08-18-2018 , 08:42   Duplicated reading?
Reply With Quote #1

For some reason my code gets duplicated, so if the original line that we have is like this
PHP Code:
;"Name" "Pw" "AccessFlags" "Prefix" 
It becomes

PHP Code:
"Name" "Pw" "AccessFlags" "Prefix"
"Name" "Pw" "AccessFlags" "Prefix"
// blank line 
Instead of just (removed ;)
PHP Code:
"Name" "Pw" "AccessFlags" "Prefix" 
Basically #1 log gets called twice while it should be called once, and I have no idea what makes the file read the same line twice.

PHP Code:
UnSuspendPlayer( const id )
{
    new const 
szTempFileName[ ] = "tempfile.ini";

    new 
szConfigs32 ], szFormat64 ], szData128 ], szDataName32 ], szDataPw32 ], szDataFlags32 ], szDataPrefix32 ], szPlayerName32 ];
    
get_configsdirszConfigscharsmaxszConfigs ) );
    
    new 
szTempFilePath256 ]; 
    
formatexszTempFilePathcharsmaxszTempFilePath ), "%s/%s"szConfigsszTempFileName );
    
    
get_user_nameidszPlayerNamecharsmaxszPlayerName ) );
    
    
formatexszFormatcharsmaxszFormat ), "%s/%s"szConfigsg_szFile );
    new 
iFilePointer fopenszFormat"rt" );
    
    if( 
iFilePointer )
    {
        new 
iInputFilePointer fopenszTempFilePath"wt" );
        
        if( 
iInputFilePointer )
        {
            while( ! 
feofiFilePointer ) )
            {            
                
fgetsiFilePointerszDatacharsmaxszData ) );
                
trimszData );
                
                
parseszDataszDataNamecharsmaxszDataName ), szDataPwcharsmaxszDataPw ), szDataFlagscharsmaxszDataFlags ), szDataPrefixcharsmaxszDataPrefix ) );
                
                
log_to_file"unsusp.txt""#1 Called" );
                                
                if( 
szDataName] == ';' // check if name has ; in it (;"DoNii" becomes ";DoNii")
                
{                    
                    if( 
equalszDataName], szPlayerName ) ) // found the admin that we're searching for
                    
{
                        
fprintfiInputFilePointer"^"%s^" ^"%s^" ^"%s^" ^"%s^"^n"szDataName], szDataPwszDataFlagsszDataPrefix ); // write to new file without ;
                        
log_to_file"unsusp.txt""#3 %s"szDataName );
                    }
                    
                    else 
// not the person we're looking for
                    
{
                        
fprintfiInputFilePointer";^"%s^" ^"%s^" ^"%s^" ^"%s^"^n"szDataNameszDataPwszDataFlagsszDataPrefix ); // write as it was before
                        
log_to_file"unsusp.txt""#3 %s"szDataName );
                    }
                }
                
                else 
// doesnt contain ;
                
{
                    
fprintfiInputFilePointer"^"%s^" ^"%s^" ^"%s^" ^"%s^"^n"szDataNameszDataPwszDataFlagsszDataPrefix ); // unknown admin, write as is
                    
log_to_file"unsusp.txt""#2 %s"szDataName );
                }
            }
            
fcloseiInputFilePointer );
            
fcloseiFilePointer );

            
delete_fileszFormat );
            
rename_fileszTempFilePathszFormat);
        }
    }
    return 
0;

Code:
L 08/18/2018 - 15:29:04: #1 Called
L 08/18/2018 - 15:29:04: #3 DoNii
L 08/18/2018 - 15:29:04: #1 Called
L 08/18/2018 - 15:29:04: #2 DoNii
__________________

Last edited by edon1337; 08-18-2018 at 12:39.
edon1337 is offline