Jump to content
Sign in to follow this  
SicSemperTyrannis

iniDB - Save and Load data to the server or your local computer without databases!

Recommended Posts

Does the @iniDB addon still works in the arma 3 beta?

Why wouldn't it?

Share this post


Link to post
Share on other sites

Hey,

Yes the addon work with A3 Beta

IniDB is awesome :yay:

OK first if you have problems about client-server communication use the ASCOM framework http://www.armaholic.com/page.php?id=19804

This should fix lot of problems.

Ok,my problem:

I need to check if a player is in the ini file.

Function:

// Executed on the server.
fncClib_verifyPlayer = {
   private ["_uid"];

_uid = _this select 0;
       _check = ["myDatabaseFile", _uid, "uid"] call iniDB_read;   //if the uid not found the return value is any,else the value is the uid

.........
_return
};

I need a bool true if uid found and bool false if not.I cant find any solution.

So i need a script to check the any return value.

I hope someone have a nice idea ;)

Phil

Edited by skullfox

Share this post


Link to post
Share on other sites

I am running a Wasteland server in ArmA 2 with this mod.

I have it saving player gear and positions but i can't seem to get it to save vehicles.

Any suggestions?

Share this post


Link to post
Share on other sites

This addon works great for me, but my rpt is spammed with this error:

_data
}>
 Error Undefined variable in expression: _type
Error in expression <s select 0;
_type = _this select 1;

if(_type == "ARRAY") then {
_string = call >
 Error position: <_type == "ARRAY") then {
_string = call >
 Error Undefined variable in expression: _type
Error in expression <_type = _this select 3;
_data = [_data, _type] call iniDB_Datarizer;
};

It doesn't seem to affect anything

Share this post


Link to post
Share on other sites
I am running a Wasteland server in ArmA 2 with this mod.

I have it saving player gear and positions but i can't seem to get it to save vehicles.

Any suggestions?

Saving vehicle positions would require a bit of work for Wasteland... I would recommend crippiling their own vehicle spawning mechanism and create your own. You would have to build an array of vehicles so each vehicle could be tracked and reset to the correct positions

This addon works great for me, but my rpt is spammed with this error:

_data
}>
 Error Undefined variable in expression: _type
Error in expression <s select 0;
_type = _this select 1;

if(_type == "ARRAY") then {
_string = call >
 Error position: <_type == "ARRAY") then {
_string = call >
 Error Undefined variable in expression: _type
Error in expression <_type = _this select 3;
_data = [_data, _type] call iniDB_Datarizer;
};

It doesn't seem to affect anything

I got that error once, it was because I failed to define if a save option was a ARRAY or not. I believe IniDB defaults to STRING when loading items and it's not specified

Share this post


Link to post
Share on other sites
Saving vehicle positions would require a bit of work for Wasteland... I would recommend crippiling their own vehicle spawning mechanism and create your own. You would have to build an array of vehicles so each vehicle could be tracked and reset to the correct positions

Sorry for a late reply.

I have worked out how to Save vehicles to the DB (Only saves used vehicles to lower the amount of work the server has to do)

Basically, when a player enters a Vehicle as Driver or Pilot (Not gunner or passenger) it saves the Vehicle to the DB.

It saves to a file called "Vehicle.ini" like this

[Owner *players UID*]

classname="MV22"

pos="[1811.9,1691.69,338.99]"

dir="202.716"

weapons="[[],[]]"

mags="[[],[]]"

Damage="0"

Fuel="1"

My problem now is i don't know how to Load the vehicles from the DB.

Any help on that would be great.

Share this post


Link to post
Share on other sites

I might be able to help you nick, add me on skype if you have it: Jordan Hachey (Canada)

Share this post


Link to post
Share on other sites
I might be able to help you nick, add me on skype if you have it: Jordan Hachey (Canada)

Alright. I'll add you now and skype you when i have some time.

Share this post


Link to post
Share on other sites

Would anyone be able to help me?

I would like to use the save player option regardless of death. Traveling a distance to get to a battle is fun, but I would like to do it only once. So once you get to the battle you would save your player. Then if you die, you would just respawn back in to the place you saved last. This would be a great help. Thanks.

Share this post


Link to post
Share on other sites
Would anyone be able to help me?

I would like to use the save player option regardless of death. Traveling a distance to get to a battle is fun, but I would like to do it only once. So once you get to the battle you would save your player. Then if you die, you would just respawn back in to the place you saved last. This would be a great help. Thanks.

It should be that way as default, for example I had to code in call for when a player dies to stop them spawning back to the same spot again.

---------- Post added at 14:02 ---------- Previous post was at 14:01 ----------

Is there anyway to use this for wasteland to give custom loadouts?

Might be better to use addWeapon, addMagazine etc for that.

Share this post


Link to post
Share on other sites

To stop a load of people wasting hours of their time, this mod DOES NOT work for the ArmA 2 Standalone as callExtension was released in OA and not ArmA 2

If anyone knows if there are mods which add the callExtension function/command then please do let me know!

Edited by JammyPear

Share this post


Link to post
Share on other sites

The latest A3 patch seemed to break this for me; anyone else having issues? I was using it to save players and locations of locked fortifications on my wasteland server; the player saving is still OK, but fortifications is broken.

I'm saving an INI which contains the names of all saved fortifications, called ObjectIndex.ini. This is what happens when I check to see if it exists:


_DBExists = ["ObjectIndex"] Call IniDB_Exists;
Diag_Log Format ["_DBExists: %1",_DBExists];
[/Code]

and in the RPT log I get

"_DBExists: false"

But the file is obviously there; in fact, if I trim it back to a couple of fortifications, it STILL returns false, but it actually loads the objects. Here's my ObjectIndex.ini file:

[ObjectIndex]

ObjectIndex="["745_Box_NATO_Wps_F","911_Land_Mil_WallBig_4m_F","940_Land_Mil_WallBig_4m_F","133_Land_Mil_WallBig_4m_F","431_Land_HBarrierBig_F","481_Land_Stone_8m_F","56_Land_Mil_WallBig_4m_F","132_Land_HBarrier_1_F","4322_Land_HBarrier_3_F","4334_Land_HBarrier_3_F","4340_Land_HBarrier_3_F","4765_Land_HBarrier_3_F","4773_Land_HBarrier_3_F","4901_Land_HBarrier_3_F","4911_Land_HBarrier_3_F","4918_Land_HBarrier_3_F",any,"5818_Land_HBarrier_3_F",any,"6255_Land_HBarrier_3_F","6264_Land_HBarrier_3_F","6324_Land_HBarrier_3_F","6366_Land_HBarrier_3_F","6407_Land_HBarrier_3_F"]"

(I'm saving the objects when they're locked by server time and object name).

Is there some limit to the length of an array that iniDB_Read can pull now? Like I said, this was all working before the patch, and I haven't made any changes.

Share this post


Link to post
Share on other sites

A good chunk of this seems to be broken with the latest arma 3 update - am I the only one experiencing this?

Share this post


Link to post
Share on other sites

I was wondering if someone could help us get our server started we are having issues with the database and maybe help us with code? We are have issues loading this into the server controls.

Share this post


Link to post
Share on other sites

I got a kludge working to get around the string length limitations on inidb.

On server restart:

LoadItemDatabase.sqf

//	@file Version: 2.0
//	@file Name: LoadItemDatabase.sqf
//	@file Author: Reaper
//	@file Created: 2013-08-08
//	@file Description: When the server starts, load items from the ObjectIndex.ini, which contains a count of possible ini files.
//	@file Args:

Private ["_ObjType","_ObjPos","_ObjDirect","_ArrayCount","_NewVeh","_ObjVectorUp","_ObjVectorDir","_DBExists","_IniFile","_i","_ActiveObjects","_ObjINIArray","_DBIndex"];
_ObjINIArray = [];
_ActiveObjects = [];

_DBExists = "ObjectIndex" Call IniDB_Exists;
Diag_Log Format ["LoadItemDatabase: _DBExists: %1",_DBExists];

//Pull the current index from the INI
_DBIndex = ["ObjectIndex","ObjectIndex","DBIndex","NUMBER"] call IniDB_Read;
Diag_Log Format ["LoadItemDatabase: _DBIndex: %1",_DBIndex];

//Ensure that we have something to load
If (_DBIndex > 0) Then {		
// Build an array of file names based upon the _DBIndex
For [{_i = 1}, {_i < (_DBIndex + 1)}, {_i = _i + 1}] do {
	_IniFile = Format ["%1_ObjArray",_i];
	Diag_Log Format ["%1_ObjArray",_i];
	_ObjINIArray = _ObjINIArray + [_IniFile];
};
Diag_Log Format ["LoadItemDatabase: Fully Constructed _ObjINIArray is %1",_ObjINIArray];
};

{// Filter through the array to find missing ini objects
_iniExists = _x Call iniDB_Exists;
Diag_Log Format ["LoadItemDatabase: Filtering Possible Objects - %1 Exists Returns %2", _x, _iniExists];
If  !(_iniExists) Then {
	_ObjINIArray - _ObjINIArray - [_x];
	Diag_Log Format ["LoadItemDatabase: Removing %1 from _ObjINIArray", _x];
};
} ForEach _ObjINIArray;

{
// check to see if the INI actually exists, to avoid errors
// _iniExists = _x Call iniDB_Exists;
// Diag_Log Format ["LoadItemDatabase: %1 exists returns %2", _x, _iniExists];
// Sleep 0.1;
// check to see if the type has been set to "delete"
//Retrieve all of the saved variables for the object.
	_ObjType = [_x,"ObjectInfo","_ObjType","STRING"] Call IniDB_Read;
	_ObjPos = [_x,"ObjectInfo","_ObjPos","ARRAY"] Call IniDB_Read;
	_ObjDirect = [_x,"ObjectInfo","_ObjDirect","SCALAR"] Call IniDB_Read;
	_ObjVectorUp = [_x,"ObjectInfo","_ObjVectorUp","ARRAY"] Call IniDB_Read;
	_ObjVectorDir = [_x,"ObjectInfo","_ObjVectorDir","ARRAY"] Call IniDB_Read;
	Sleep 0.1;
	Diag_Log Format["LOADING FROM ITEM DATABASE: _ObjType: %1 _ObjPos: %2: _ObjDirect: %3 _ObjVectorUp: %4 _ObjVectorDir: %5",_ObjType,_ObjPos,_ObjDirect,_ObjVectorUp,_ObjVectorDir];
	//Create the object (vehicle)
	_NewVeh = createVehicle [_ObjType,_ObjPos,[],0,"None"];
	// Set the position exactly, because CreateVehicle will fuck around with objects.
	_NewVeh setPos _ObjPos;

	//I'm trying this command to try and better capture it's location and direction
	_NewVeh setVectorDirAndUp [_ObjVectorDir,_ObjVectorUp];

	// the Obj_DBIndex is a variable that contains the name of the database where the object info is stored.
	_NewVeh SetVariable ["Obj_DBIndex", _x, True];
	_NewVeh setVariable ["objectLocked", True, True];

	// Build a list of the active objects that are being loaded.
	_ActiveObjects = _ActiveObjects + [_NewVeh];
	Sleep 0.1;


} ForEach _ObjINIArray;


ActiveObjects = _ActiveObjects;
ObjINIArray = _ObjINIArray;
DBIndex = _DBIndex;
PublicVariable "ActiveObjects";
PublicVariable "ObjINIArray";
PublicVariable "DBIndex";



When an object is locked through the mouse wheel, it updates the global variable ObjectSaveRelay, which, through the Publicvariableeventhandler triggers this code:

ObjSaving.sqf

//	@file Version: 2.0
//	@file Name: ObjSaving.sqf
//	@file Author: Reaper
//	@file Created: 2013-08-08
//	@file Description: When an object is locked, save it to the server. Since we're using
//	iniDB, I guess the easiest thing to do will be to save files as array elements. I tried
// saving them in one long array, but there must be a max return limit on characters rom iniDB_Read, because after saving maybe two dozen
// items, it would no longer read values back.
//	@file Args: 


Private["_NewObject","_ObjType","_ObjPos","_ObjDirect","_DBCheck","_ObjINIArrayEntry","_NewDBIndex","_ObjVectorUp","_ObjVectorDir"];
// ObjectSaveRelay has been updated, so store it to a private variable.
_NewObject = ObjectSaveRelay;
Sleep 0.1;

_ObjType = TypeOf _NewObject;
_ObjPos = Position _NewObject;
_ObjDirect = Direction _NewObject;
_ObjVectorUp = vectorUp _NewObject;
_ObjVectorDir = vectorDir _NewObject;


// Check to see if the object already has an array entry (unlocked and then relocked).
// If the Obj_DBIndex variable isn't nil, use it for saving (object was previously saved, then unlocked)
If !(isNil{_NewObject GetVariable "Obj_DBIndex";}) Then {
_ObjINIArrayEntry = _NewObject GetVariable "Obj_DBIndex";
Diag_Log Format ["ObjSaving: _ObjINIArrayEntry is %1_ObjArray", _ObjINIArrayEntry]; 
};

// Object has never been saved
If (isNil {_NewObject GetVariable "Obj_DBIndex"}) then {
DBIndex = DBIndex + 1;
PublicVariable "DBIndex";

_NewDBINdex = DBIndex; // Use the incremented index for the new object ini 
_NewDBIndex = Format ["%1_ObjArray",_NewDBIndex];
Diag_Log Format ["ObjSaving: Object has no INI array entry, it is being created as %1",_NewDBIndex];
_NewObject SetVariable ["Obj_DBIndex", _NewDBIndex, True];
ObjINIArray = ObjINIArray + [_NewDBIndex];
PublicVariable "ObjINIArray";
_ObjINIArrayEntry = _NewDBIndex;

} else {
_ObjINIArrayEntry = _NewObject GetVariable "Obj_DBIndex";
//ObjINIArray = ObjINIArray + [_NewDBIndex];
PublicVariable "ObjINIArray";
};

// Push the updated count into the database, so we know how many object entries have been made, to sort through
// on server start.
["ObjectIndex","ObjectIndex","DBIndex",DBIndex] Call IniDB_Write;

// create/update a database ini file for the object
[_ObjINIArrayEntry,"ObjectInfo","_ObjType",_ObjType] Call IniDB_Write;
[_ObjINIArrayEntry,"ObjectInfo","_ObjPos",_ObjPos] Call IniDB_Write;
[_ObjINIArrayEntry,"ObjectInfo","_ObjDirect",_ObjDirect] Call IniDB_Write;
[_ObjINIArrayEntry,"ObjectInfo","_ObjVectorUp",_ObjVectorUp] Call IniDB_Write;
[_ObjINIArrayEntry,"ObjectInfo","_ObjVectorDir",_ObjVectorDir] Call IniDB_Write;

// Update the index database with the new file name

ActiveObjects = ActiveObjects + [_NewObject];
PublicVariable "ActiveObjects";
Diag_Log Format ["ObjSaving: ObjSaving: Active Objects are %1", ActiveObjects];
Diag_Log Format ["ObjSaving: ObjSaving: ObjectDBIndex is %1", ObjINIArray];
Diag_Log Format ["ObjSaving: ObjSaving: New DBIndex is %1", DBIndex];



// Diag_Log Format ["ObjSaving: Object %1 has been flagged for storage", _NewObject];
// ObjectArray = ObjectArray + [_ObjType,_ObjPos,_ObjDirect];

// Push the object array to the database
// ["ObjectDatabase","ObjectDatabase","ObjectArray",ObjectArray] Call IniDB_Write;

The exact same thing happens when an object is unlocked, triggering this code: ObjRemoval.sqf

//	@file Version: 1.1
//	@file Name: ObjRemoval.sqf
//	@file Author: Reaper
//	@file Created: 2013-08-08
//	@file Description: Remove an item from the DB when it's unlocked
//	@file Args:

Private ["_ObjType","_ObjPos","_ObjDirect","_RemObj","_ObjINIArrayEntry","_ActiveObjects","_ObjINIArray"];

_RemObj = ObjectRemoveRelay;
_ActiveObjects = ActiveObjects;
_ObjINIArray = ObjINIArray;
Diag_Log Format ["Object %1 passed for removal",_RemObj];

//If the vehicle is in the active array
If (_RemObj In _ActiveObjects) Then 
{	Diag_Log Format ["Object Array currently is %1", _ActiveObjects];
// The index name is supposed to be saved with the object as a variable, so pull it
// so that we know which ini file needs to be removed.
_ObjINIArrayEntry = _RemObj GetVariable "Obj_DBIndex";
_ObjINIArray = _ObjINIArray - [_ObjINIArrayEntry];

// Remove the database file
_ObjINIArrayEntry call IniDB_Delete;
_ActiveObjects = _ActiveObjects - [_RemObj];
Diag_Log Format ["_ActiveObjects Array Trimmed to %1",_ActiveObjects];

//["ObjectIndex","ObjectIndex","ObjectIndex",_ObjINIArray] Call IniDB_Write;
} Else {
Diag_Log Format ["Object %1 is not in the array!", _RemObj];
};

It has a lot of cruft in it, because I took the previous method of saving and loading objects and kind of incrementally adapted it, but it works. I set up a base of ~ 20 walls and stands, and they survived a server reboot just fine. One gap is that the current lock code stores the side of the player who locked it, preventing other players from removing the object if the locking side is near by. That's just another variable I'll have to set at some point.

Eventually I'll add a function during the load process that eliminates gaps in the array, but since they only effect performance immediately upon server load (iterating through arrays checking for valid files), it's kind of low on the priorities. Next up, purchased vehicle saving!

Share this post


Link to post
Share on other sites

Question, when I run the @inidb mod on my server, I get a yellow exclamation point next to the server name in the listings. How can I get rid of this? It tends to turn players off thinking there is a problem with the server.

Share this post


Link to post
Share on other sites
Question, when I run the @inidb mod on my server, I get a yellow exclamation point next to the server name in the listings. How can I get rid of this? It tends to turn players off thinking there is a problem with the server.

IIRC that is due to them not having the same mods that the server runs. Nothing to worry about - just uneducated players.

Share this post


Link to post
Share on other sites

Unfortunately there are quite a few of those... I just didn't know if anyone had found a workaround to restore the green icon. Thanks!

Share this post


Link to post
Share on other sites

Is there a way to have a sub directory in "@inidb\db"? I want to create a Players folder and save ini files per user

Share this post


Link to post
Share on other sites

Ever since I put this on my server no one ever joins anymore. I think the reason is due to the 'uneducated players'! Is there anyway to run this as part of the mission vs running it as a mod.

Share this post


Link to post
Share on other sites

I don't know how to write a script, but I can read a sample. So anyone could help me write a little code for me with iniDB?

I need a check function:

In server side, a GUID.ini file, it's a GUID list. What are the contents of the GUID.ini file?

In Client side, I need let's get GUID from server.

As below code, this is my old code:

 if (local player) then 
    {
    switch (getplayerUID player) do
    {
      case "15438342" :       
      {
       player setVariable ["perm_air", 1];

      };

How I can change "15438342" to get variable from GUID.ini?

Thanks!

Edited by cccbss

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
Sign in to follow this  

×