Load INI files
#1

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
Reply
#2

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

Ok thanks
Reply
#4

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

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
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)