PDA

View Full Version : How To Make This???


Joco5
10/12/2011, 09:41 PM
For every new player dont create new.txt with his phonenumber in it, i want to make it save in one file.
Name Number
Name Number
Name Number
etc


Tnx.

On Player Connect
new pfile[20];
GetPlayerName(playerid, pfile, 16);
format(pfile, sizeof(pfile), "%s.txt", pfile);
if (fexist(pfile))
{
new File:ftw = fopen(pfile, io_read);
new tmp[5];
fread(ftw, tmp);
AccInfo[playerid][number] = strval(tmp);
fclose(ftw);
}
else
{
do
{
AccInfo[playerid][number] = 1000 + random(8999);
}
while(NumberUsed(playerid));

new File:handle1 = fopen(pfile, io_write);
new tmp[6];
format(tmp, 5, "%d", AccInfo[playerid][number]);
fwrite(handle1, tmp);
fclose(handle1);
new File:handle2;
if (!fexist("numbers_used.txt"))
{
format(tmp, 7, "%d", AccInfo[playerid][number]);
handle2 = fopen("numbers_used.txt", io_write);
fwrite(handle2, tmp);
fclose(handle2);
}
else
{
format(tmp, 7, "\r\n%d", AccInfo[playerid][number]);
handle2 = fopen("numbers_used.txt", io_append);
fwrite(handle2, tmp);
fclose(handle2);
}
}

sansko
10/12/2011, 09:42 PM
use [pawn] tags to put code in