files number
#1

hi I wanna know if samp have fuction who return number of file in directory, thx and sorry or bad english.
Reply
#2

No You must add every filename to a single file or name file 1.ini,2.ini... xd
Reply
#3

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.
Reply
#4

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
}
Reply
#5

So what if files are:
File_0.ini
File_1.ini
File_3.ini
File_4.ini
?
returns 2 ?
Reply
#6

Yes.
Reply
#7

I know xD but he need to count files.
Reply
#8

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.
Reply
#9

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.
Reply
#10

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);
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)