help fwrite read file - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: help fwrite read file (
/showthread.php?tid=555474)
help fwrite read file -
ombre - 07.01.2015
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.
Re: help fwrite read file -
Divergent - 07.01.2015
What's your question?
Re: help fwrite read file -
ombre - 07.01.2015
yes bad edit. it's ok now
Re : help fwrite read file -
ombre - 09.01.2015
up plz