Line removing problem
#1

I'm trying to remove player name from file but it doesn't getting removed!! I dont understand i did everything to the samp wiki tutorial and yet, its there when the code executed.. -.-

I'm writing to a line names this way: "Firstname_Lastname\r\n". (Getting playername and just writing it inside)

removeline function:
Код:
stock fremoveline( filename[ ], line[ ] )
{
	if( fexist( filename ) )
	{
		new
		szTmp[ 256 ],
		File: fHandle = fopen( filename, io_read ),
		File: fBullshit = fopen( "loltmp.ini", io_write )
		;
		while( fread( fHandle, szTmp ) )
		{
			if( strfind( szTmp, line ) == -1 )
			{
				fwrite( fBullshit, szTmp );
			}
		}
		fclose( fHandle );
		fclose( fBullshit );
		fremove( filename );
		
		fHandle = fopen( filename, io_append );
		fBullshit = fopen( "loltmp.ini", io_read );
		
		while( fread( fBullshit, szTmp ) ) {
			fwrite( fHandle, szTmp );
		}
		fclose( fHandle );
		fclose( fBullshit );
		fremove( "loltmp.ini" );
		
		return 1;
	}
	return 0;
}
here is the code which should remove the line:
pawn Код:
new playerName[24];
new str[128], pname[24];
new File:gstats=fopen("passed.ini", io_append);
GetPlayerName(playerid, pname, 24); // The name of the player
format(str, sizeof(str), "%s\r\n",pname); // format
while(fread(gstats, string))
{
    if(strcmp(string, pname, false, strlen(pname))==0)
    {
        fremoveline("passed.ini", str);
    }
}
What happens in the file afterwards? noting. please help.
Reply


Messages In This Thread
Line removing problem - by maximthepain - 09.07.2015, 11:34
Re: Line removing problem - by Threshold - 09.07.2015, 12:13
Re: Line removing problem - by maximthepain - 09.07.2015, 18:42
Re: Line removing problem - by Threshold - 10.07.2015, 06:13
Re: Line removing problem - by maximthepain - 11.07.2015, 09:40
Re: Line removing problem - by Threshold - 11.07.2015, 10:59
Re: Line removing problem - by maximthepain - 11.07.2015, 12:39

Forum Jump:


Users browsing this thread: 1 Guest(s)