What is the best file reader (With TAGS)
#1

Hey everyone,

I'm currently looking for the best file reader include or plugin to read from a file that can be easily edited with a text editor or program. I will be using it to load multiple objects into the game and want to ability to add more to the file so it can be loaded on the fly (Dynamically)

Structure of file
Код:
NonTagedData = nottaged

[Object 1]
ObjectID = xxx
ObjectPosX = xxx.xxx
ObjectPosY = xxx.xxx
ObjectPosZ = xxx.xxx

[Object 2]
ObjectID = xxx
ObjectPosX = xxx.xxx
ObjectPosY = xxx.xxx
ObjectPosZ = xxx.xxx

[Object 3]
ObjectID = xxx
ObjectPosX = xxx.xxx
ObjectPosY = xxx.xxx
ObjectPosZ = xxx.xxx

[Object 4]
ObjectID = xxx
ObjectPosX = xxx.xxx
ObjectPosY = xxx.xxx
ObjectPosZ = xxx.xxx
ISLAST = 1
Then I have a function something like
NOTE: wrote this code here on the forum (EXAMPLE ONLY)
Код:
new ID,
	Float:x,
	Float:y,
	Float:z,
	nottaggeddata[32];

for(new i=1; i<MAX_OBJECTS; i++)
{
	new ISLAST = 0;
	new file = file_read("Objects.ini");
	new str[32];
	
	file_String(file, "", "NonTagedData", nottaggeddata, 32);
	
	format(str, 32, "Object %i", i);
	
	ID = file_Int(file, str, "ObjectID");
	x = file_Float(file, str, "ObjectPosX ");
	y = file_Float(file, str, "ObjectPosY ");
	z = file_Float(file, str, "ObjectPosZ ");
	ISLAST = file_Int(file, str, "ISLAST");
	
	CreateObject(ID, x, y, z);
	
	if(ISLAST) break;
}
I've been looking at a few different options but from what I can see none really want to do what I want.
y_ini, dini, dini2, sqlite, djson, xml reader

Some of these may do what I want Such as XML reader will. However its not the easiest thing to edit and you have to put tags on everything. This is the same with djson i believe. I am wanting something simple like the INI format of things, but cant find a way of easily reading while in a loop.
Reply
#2

If your aim really is to load object then you can use this : https://sampforum.blast.hk/showthread.php?tid=489765
I also made a system to do something same, here is the link : https://github.com/xxxZeus/Dynamic-m...-SA-MP-servers


Use sqlite/mysql that will be the simplest and fastest approach. You will need to create a table say objects and create columns like x,y,z,rx..etc. And you can then simply load all objects with query "SELECT * FROM objects".

If you don't want to use a plugin then use sqlite if you can then use mysql since its faster.

INI approach for this thing would be tremendously slow as compared to mysql, as there will be thousands of objects and for each object you need tag and four different lines for storing its info. It will take time to read those file using pawn natives(used in ini readers) and it will make file size ridiculously large too.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)