help fwrite read file
#1

Hello,

I want to use this command for : check if my name is in a file (names.txt) and if yes to add in the file "OKwrite"

Код:
if (strcmp(cmd, "/test", true) ==0 )
     	if(IsPlayerConnected(playerid))
	    {
		    new plname[24];
		    GetPlayerName(playerid, plname, 24); // The name of the player
		    new File:file;
		    file = fopen("names.txt",io_readwrite);
		    if (file)
		    {
		        printf("1");
		        while(fread(file,string,sizeof(string)))
		        {
		            printf("2");
		            if (strfind(string, plname, true) != -1)
		            {
		                printf("3");
				fwrite(file,"OKwrite");
			        }
		    	}
		    	printf("4");
		    	fclose(file);
		    }
		}
	    return 1;
	}
Код:
names.txt :

Name_1
Name_2
My_Name
The command work's I has:
1
2
1
2
1
2
3 => read
4

But the file it's no edit ( no add "OKwrite" ). Why? I believe it's "if (strfind(string, plname, true) != -1)" if i remove it. it's work but it doesn't check my name.

Regard.
Reply
#2

What's your question?
Reply
#3

yes bad edit. it's ok now
Reply
#4

up plz
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)