files number - 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: files number (
/showthread.php?tid=307983)
files number -
jaskiller - 01.01.2012
hi I wanna know if samp have fuction who return number of file in directory, thx and sorry or bad english.
Re: files number -
Jefff - 01.01.2012
No You must add every filename to a single file or name file 1.ini,2.ini... xd
Re: files number -
Mauzen - 01.01.2012
Scripted solutions are either epic slow or not working.
Check the plugin section, I think there is a plugin that offers that function, or something similar.
Re: files number -
FTLOG - 01.01.2012
No, but i use custom functions and loops like this, for example.
Код:
GetFreeFileSlot( ) {
new
FileName[ 20 ],
Slot = 0; // Or minumum file number.
for( new i = 0; i < MAX_FILE_NUMBER; i++ ) { //Loop from zero to whatever MAX_FILE_NUMBER you set
format( FileName, sizeof( FileName ), FILE_PATH "File_%d.ini", i );
if( fexist( FileName )) Slot++; // If slot exists, continue...
else break; // If slot doesn't exist, break the loop and...
}
return Slot; // ...return the value
}
Re: files number -
Jefff - 01.01.2012
So what if files are:
File_0.ini
File_1.ini
File_3.ini
File_4.ini
?
returns 2 ?
Re: files number -
FTLOG - 01.01.2012
Yes.
Re: files number -
Jefff - 01.01.2012
I know xD but he need to count files.
Re: files number -
FTLOG - 01.01.2012
Quote:
Originally Posted by Jefff
I know xD but he need to count files.
|
Well, yeah, i just assumed he needs to count files to get the free slot or something.
Re: files number -
Mauzen - 02.01.2012
If it is just that you could create a new ini file to store the current filecount in, so you can load it, increase it and then safe it again later when creating a new file.
Re: files number -
Babul - 02.01.2012
another way to achieve that, is to make a "catalogue" file, storing all directories' files, iam using this trick in the fireworks2 script, it works well
Код:
new File:fFireworksCat=fopen("FireworksCat.txt",io_readwrite);
while(fread(fFireworksCat,ValCat))
{
if(!sscanf(ValCat,"d",Type))
{
format(filename,sizeof(filename),"Fireworks/%05d.txt",Type);
new File:fFireworks=fopen(filename,io_readwrite);