03.05.2011, 15:36
I was just testing this out a few days ago using commands to read and write using Sscanf, Here's my code I used to test with if it could be of any help:
Write
Read
(It searches for the line that starts with the word written into the command param.)
Write
pawn Код:
new v1,v2,str[20],string[128];
if (sscanf(params, "sii", str,v1,v2)) return SendClientMessage(playerid, 0xEFEFF7AA, "* USAGE: /Savetest [Name] [Value] [Value] ");
new File:pos=fopen("Testing.txt", io_append);
format(string, 256, "%s %i %i\r\n",str,v1,v2);
SendClientMessage(playerid,0xEFEFF7AA,string);
fwrite(pos, string);
fclose(pos);
pawn Код:
new str[20], str2[50];
new name[20], v1,v2;
new string[256];
if (sscanf(params, "s", str)) return SendClientMessage(playerid, 0xEFEFF7AA, "* USAGE: /Loadtest [Name]");
new File:pos=fopen("Testing.txt", io_read);
while(fread(pos, str2))
{
if(!sscanf(str2, "sii", name,v1,v2))
if(!strcmp(name,str,true))
{
format(string, 256, "[FOUND] Name: %s | Values: %i and %i",str,v1,v2);
SendClientMessage(playerid,0xEFEFF7AA,string);
break;
}
}
fclose(pos);