09.07.2015, 11:34
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:
here is the code which should remove the line:
What happens in the file afterwards? noting. please help.
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; }
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);
}
}