SA-MP Forums Archive
Create File [REP++] - 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: Create File [REP++] (/showthread.php?tid=559136)



Create File [REP++] - nezo2001 - 21.01.2015

Hello ,
I want to create a file to store in it all gang info but not like this
PHP код:
= ...
= ...
= .... 
Because they are 65 zone or if you know how to make 65 file so tell me in this way .
Thank You !


Re: Create File [REP++] - Schneider - 21.01.2015

//whenever you want to save the gangs in multiple files you just have to format the filepath;
pawn Код:
for(new i; i<NUMBER_OF_GANGS; i++)
{
    new filepath[64];
    format(filepath, sizeof(filepath), "Gangs/%d",  i);
    dini_Create(filepath);
    .. et cetra
}
or if you want to save all info in 1 file (1 line per gang) you could do something like this:
pawn Код:
new File:file=fopen("GangInfo.txt", io_append);
new str[128];
for(new i; i<NUMBER_OF_GANGS; i++)
{  
    format(str, sizeof(str), "%s %.2f %.2f %.2f \r\n", GangInfo[i][GangName], GangInfo[i][X], GangInfo[i][Y], GangInfo[i][Z]);
    fwrite(file, str);
}
fclose(file);



Re: Create File [REP++] - nezo2001 - 21.01.2015

Can you explain more for the one file i am not so good in saving


Re: Create File [REP++] - Schneider - 21.01.2015

I'm sorry, now that I think of it, this is not the right way to do it. I got this little piece of code from my KeepYourLane-filterscript I released a while back which saves and reads lots data(coordinates) from 1 single file. But in my script the values won't get changed, while i assume the gang-values you want to store do change, so this will not work for you. And to be honest I don't know how to do that.. I'm only familiar with dini, but that will give you lots of files.

I could explain that a bit more to you, unless you prefer someone else explain the 1-file saving system..


Re: Create File [REP++] - nezo2001 - 21.01.2015

Another thing.....
How can i load them in GangZoneCreate ?