SA-MP Forums Archive
Reading and loading from a text 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: Reading and loading from a text file (/showthread.php?tid=559807)



Reading and loading from a text file - TonyII - 25.01.2015

Hey guys, so I just want to save and load a few variables, I tought the best way to do this would be with a .txt or a .ini file. So after searching for more information on both sides I ended up with an unfinished code, stuck without a clue. I barely had an idea of what I was doing but this is what I got
pawn Код:
//saving
fremove("headquarters.txt");
new File:file = fopen("headquarters.txt", io_append),logs[178];
for(new i = 0; i < 5; i++)
{
    format(logs,sizeof(logs),"hq%d = %d\r\n",i,hq[i]);
    fwrite(file,logs);
}
fclose(file);

//loading, what I want here is that it stores the numbers back into the variables
new File:file = fopen("headquarters.txt", io_read);
while(fread(file,string))
{
}