Raised This Month: $32 Target: $400
 8% 

Solved Duplicated reading?


Post New Thread Reply   
 
Thread Tools Display Modes
edon1337
Penguin Enthusiast
Join Date: Jun 2016
Location: Macedonia
Old 08-18-2018 , 15:47   Re: Duplicated reading?
Reply With Quote #11

Quote:
Originally Posted by HamletEagle View Post
What do you mean? The entire line should be copied.
Well, should be, but isn't, because I'm parsing only 4 arguments, but I can't parse comments..
__________________
edon1337 is offline
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 08-18-2018 , 16:21   Re: Duplicated reading?
Reply With Quote #12

This are not comments... It will be part of last argument.
__________________

Last edited by HamletEagle; 08-20-2018 at 14:12. Reason: nvm I'm talking bullshit
HamletEagle is offline
edon1337
Penguin Enthusiast
Join Date: Jun 2016
Location: Macedonia
Old 08-18-2018 , 16:43   Re: Duplicated reading?
Reply With Quote #13

Quote:
Originally Posted by HamletEagle View Post
This are not comments... It will be part of last argument.
Oh so

PHP Code:
"Msg1" "Msg2" "Msg3" "Msg4" // Important info 
Code:
parse( Data, msg1, charsmax( msg1 ), msg2, charsmax( msg2 ), msg3, charsmax( msg3 ), msg4, charsmax( msg4 ) )

msg4 will be like this?
Code:
"Msg4 // Important info"
__________________

Last edited by edon1337; 08-18-2018 at 16:43.
edon1337 is offline
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 08-19-2018 , 05:35   Re: Duplicated reading?
Reply With Quote #14

Why don't you just test?
__________________
HamletEagle is offline
edon1337
Penguin Enthusiast
Join Date: Jun 2016
Location: Macedonia
Old 08-19-2018 , 05:38   Re: Duplicated reading?
Reply With Quote #15

Quote:
Originally Posted by HamletEagle View Post
Why don't you just test?
Well, I obviously have tested, that's why I asked that question to KliPPy. It doesn't copy the comments into the new file.
__________________
edon1337 is offline
shauli
Member
Join Date: Jun 2018
Old 08-19-2018 , 08:08   Re: Duplicated reading?
Reply With Quote #16

Quote:
Originally Posted by edon1337 View Post
Well, I obviously have tested, that's why I asked that question to KliPPy. It doesn't copy the comments into the new file.
You can't do it with parse, maybe with argbreak or strbreak.
But there is an easier way here. You are actually never using szDataPw, szDataFlags or szDataPrefix, you're parsing it for no reason, you only need the szDataName.

So instead of parsing all arguments and re-format them to your file, just parse the first argument (szDataName), do you checks, and write szData as a whole.

Here's an example:
PHP Code:
    fgetsiFilePointerszDatacharsmaxszData ) ); 
    
trimszData ); 
    
    
parseszDataszDataNamecharsmaxszDataName ) ); 
    
    
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 
        

            
fprintfiInputFilePointerszData] ); // write to new file without ; 
            
log_to_file"unsusp.txt""#3 %s"szDataName ); 
        }
    
        else 
// not the person we're looking for 
        

            
fprintfiInputFilePointerszData ); // write as it was before 
            
log_to_file"unsusp.txt""#3 %s"szDataName ); 
        } 
    } 
    
    else 
// doesnt contain ; 
    

        
fprintfiInputFilePointerszData ); // unknown admin, write as is 
        
log_to_file"unsusp.txt""#2 %s"szDataName ); 
    } 
Tell me if it's working as excepted.
shauli is offline
edon1337
Penguin Enthusiast
Join Date: Jun 2016
Location: Macedonia
Old 08-19-2018 , 11:54   Re: Duplicated reading?
Reply With Quote #17

Quote:
Originally Posted by shauli View Post
You can't do it with parse, maybe with argbreak or strbreak.
But there is an easier way here. You are actually never using szDataPw, szDataFlags or szDataPrefix, you're parsing it for no reason, you only need the szDataName.

So instead of parsing all arguments and re-format them to your file, just parse the first argument (szDataName), do you checks, and write szData as a whole.

Here's an example:
PHP Code:
    fgetsiFilePointerszDatacharsmaxszData ) ); 
    
trimszData ); 
    
    
parseszDataszDataNamecharsmaxszDataName ) ); 
    
    
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 
        

            
fprintfiInputFilePointerszData] ); // write to new file without ; 
            
log_to_file"unsusp.txt""#3 %s"szDataName ); 
        }
    
        else 
// not the person we're looking for 
        

            
fprintfiInputFilePointerszData ); // write as it was before 
            
log_to_file"unsusp.txt""#3 %s"szDataName ); 
        } 
    } 
    
    else 
// doesnt contain ; 
    

        
fprintfiInputFilePointerszData ); // unknown admin, write as is 
        
log_to_file"unsusp.txt""#2 %s"szDataName ); 
    } 
Tell me if it's working as excepted.
Thank you!

There is just one flaw, after this function is completed the line becomes like this
PHP Code:
Name" "123" "abc" "[BLABLA]
Notice the missing " at the front of the line

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

    new 
szConfigs32 ], szFormat64 ], szData128 ], szDataName32 ], 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( 
fgetsiFilePointerszDatacharsmaxszData ) ) )
            {            
                
trimszData );  
                
                
parseszDataszDataNamecharsmaxszDataName ) );  
                
                if( 
szDataName] == ';' // check if name has ; in it (;"DoNii" becomes ";DoNii")  
                
{            
                    if( 
equalszDataName], szPlayerName ) ) // found the admin that we're searching for  
                    
{
                        
formatexszDatacharsmaxszData ), "%s^n"szData] );
                        
fprintfiInputFilePointerszData] ); // write to new file without ;
                    

                    
                    else 
// not the person we're looking for
                    
{
                        
formatexszDatacharsmaxszData ), "%s^n"szData );
                        
fprintfiInputFilePointerszData ); // write as it was before  
                    
}
                }  
                
                else 
// doesnt contain ;  
                
{  
                    
formatexszDatacharsmaxszData ), "%s^n"szData );
                    
fprintfiInputFilePointerszData ); // unknown admin, write as is  
                
}  
            }
            
fcloseiInputFilePointer );
            
fcloseiFilePointer );

            
delete_fileszFormat );
            
rename_fileszTempFilePathszFormat);
        }
    }
    return 
0;

__________________
edon1337 is offline
shauli
Member
Join Date: Jun 2018
Old 08-19-2018 , 14:14   Re: Duplicated reading?
Reply With Quote #18

Quote:
Originally Posted by edon1337 View Post
Thank you!

There is just one flaw, after this function is completed the line becomes like this
PHP Code:
Name" "123" "abc" "[BLABLA]
Notice the missing " at the front of the line
You erased the first character twice.
PHP Code:
formatexszDatacharsmaxszData ), "%s^n"szData] ); 
fprintfiInputFilePointerszData] ); // write to new file without ; 
shauli is offline
edon1337
Penguin Enthusiast
Join Date: Jun 2016
Location: Macedonia
Old 08-20-2018 , 04:20   Re: Duplicated reading?
Reply With Quote #19

Quote:
Originally Posted by shauli View Post
You erased the first character twice.
PHP Code:
formatexszDatacharsmaxszData ), "%s^n"szData] ); 
fprintfiInputFilePointerszData] ); // write to new file without ; 
Ah, thanks
__________________

Last edited by edon1337; 08-20-2018 at 04:21.
edon1337 is offline
Reply



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 11:44.


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