SA-MP Forums Archive
Load INI files - 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: Load INI files (/showthread.php?tid=639879)



Load INI files - Inuro - 24.08.2017

Hey
I have a little problem. I have create a INI dynamic mapping system in game.
The admin can save the project like "mapping1" and it saved in the scriptfiles

how to load many .txt files when server start ? The server must recover the files present and load them

thanks


Re: Load INI files - Vince - 24.08.2017

If the files can be named whatever the user wants then you have no way of retrieving the names of those files because there isn't a native that can list the directory contents. There are certain file manager plugins that may provide the solution but I don't know how up-to-date those are or even if they work across different operating system.

Another potential solution is to store a list of filenames inside another (flat) file. That file can then be read with a simple "while fread" loop. The downside is that problems will start to arise as soon as you want to modify or remove one of those filenames. This involves a lot of string comparison, which is already fairly slow, and then the entire file needs to be rewritten. This gets worse as the file grows larger.

Consider using SQL (SQLite) if you want something more durable.


Re: Load INI files - Inuro - 24.08.2017

Ok thanks


Re: Load INI files - Inuro - 24.08.2017

It's not possible to load a FOLDER with all .txt in this folder ?


Re: Load INI files - thegamer355 - 24.08.2017

You could use the filemanager plugin to load an entire folder with files, i've done this with my maploader.
Wasn't easy to make, but it's possible, take a look at Paddy's Map Loader, this works in the same way.
Which can be found here!

It would require a total rescripting of that include, but the basics are the same, loop through all files in the folder and do something with it.

This include only reads .pml files, but if you change the .pml to .txt it will load all txt files

Hope this helps you