Jump to content
7erra

BIS_fnc_db Functions

Recommended Posts

Does anyone have experience with the database functions of arma? How can I use them to make a database? I was not able to figure out what the arrray, that the database is, is supposed to look like.

 

BIS_fnc_dbSymbolClass
BIS_fnc_dbSymbolValue
BIS_fnc_dbisClass
BIS_fnc_dbisValue
BIS_fnc_dbClassId
BIS_fnc_dbClassSet
BIS_fnc_dbClassCheck
BIS_fnc_dbClassIndex
BIS_fnc_dbClassRemove
BIS_fnc_dbClassReturn
BIS_fnc_dbClassList
BIS_fnc_dbValueId
BIS_fnc_dbValueSet
BIS_fnc_dbValueCheck
BIS_fnc_dbValueIndex
BIS_fnc_dbValueRemove
BIS_fnc_dbValueReturn
BIS_fnc_dbValueList
BIS_fnc_dbImportConfig
BIS_fnc_dbImportXML
BIS_fnc_dbConfigPath
BIS_fnc_dbPrint

 

Directory: a3\functions_f\database

Seems to have been introduced with TKOH.

  • Like 1

Share this post


Link to post
Share on other sites

Okay so here is the format of the database:

[// Imported with BIS_fnc_dbImportXML (db.xml)
	"#XML",[], // ???
	"#PLAYERS",// Class
	[
		"#TERRA", // SubClass0
		[
			"&MONEY","100","&RANK","COLONEL","&UID","123456" // Values of SubClass0
		],
		"#AASGEYER", // SubClass1
		[
			"&MONEY","50","&RANK","PRIVATE","&UID","789102" // Values of SubClass1
		]
	]
]

Here is the db.xml that I used:

<?xml version="1.0"?>
<players>
	<terra>
		<money>100</money>
		<rank>COLONEL</rank>
		<uid>123456</uid>
	</terra>
	<aasgeyer>
		<money>50</money>
		<rank>PRIVATE</rank>
		<uid>789102</uid>
	</aasgeyer>
</players>

 

The next problem is to figure out how to access and modify the database.

  • Like 2

Share this post


Link to post
Share on other sites
19 hours ago, 7erra said:

Does anyone have experience with the database functions of arma?

Never seen these before.

 

11 hours ago, 7erra said:

The next problem is to figure out how to access and modify the database.

These are script functions, they can only do the stuff that script commands offer to you.
You might aswell just write your own code and save things into profileNamespace.

Share this post


Link to post
Share on other sites

Yeah the (very rare) documentation states that the database is only a scripted one. This means that during mission runtime there is a global array which gets accessed and modified. This array could be saved to profilenamespace at the end of the mission or when appropriate. My current approach is the BIS_fnc_addToPairs functions and the related functions. But having such a functions library at hand seems quite intriguing once I've figured out how to do it 🤔. Will keep this updated.

  • Like 1

Share this post


Link to post
Share on other sites

Okay so here is how to operate a scripted database with the BI functions:

/* Declaration of the databse
First of all there has to be an array which fits the database format.
This format is the following:

[
	"#CLASS_0", 
	[
		"#SUBCLASS_0_0",
		[
			"&VALUE_0_0_0", 0,
			"&VALUE_0_0_1", 1,
			"&VALUE_0_0_3", "anything"
		],
		"#SUBCLASS_0_1",
		[
			"&VALUE_0_1_0", 0,
			"&VALUE_0_1_1", 1,
			"&VALUE_0_1_2", "anything"
		]
	],
	"#CLASS_1",
	[
		// anything
	]
]

*/
//--- EXAMPLE:
// _db uses the uid to save stats to a database
_db = ["#PLAYERS",["#1234",["&NAME","Terra","&MONEY",100,"&RANK","COLONEL"]]];
// The money stat can be accessed with
_pathMoney = ["players","1234","money"];
// The class ("#") and value ("&") symbol are ignored and the search is case insensitive
//--- Get money
// The database _db is accessed at the given path. The value that fits the variable is returned.
_money = [_db, _pathMoney] call BIS_fnc_dbValueReturn;
//--- Set new money
// Passing an array to the function modifies the array. If the class(es) is(/are) non existent, it(/they) are created.
[_db, _pathMoney, _money +100] call BIS_fnc_dbValueSet;
_db // returns new database

 

So basically when there is a "path" parameter it is comparable to a config entry. Instead of using the >> operator you simply change it to an array:

// Config:
getNumber ("players" >> "1234" >> "money");
// DB:
[_db, ["players", "1234", "money"]] call BIS_fnc_dbValueReturn;

 

I wonder why these functions were forgotten even though they can be used to create a pretty neat database?

  • Like 1

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

×