Jump to content
code34

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

Recommended Posts

The intention of this mod is to load it on the server through the command line -serverMod=@inidbi2;

 

Then you MUST call all functions dealing with iniDBI2 on the server, or clients will get an error because said function does not exist.

 

You could have clients required to have this mod, and then save data on the clients machine, but then that data could easily be changed by the client, which would compromise whatever your trying to do.

 

If the above doesn't make sense to you, (no offense) then this might be too advance for you. I suggest starting with something smaller and then come back to using iniDBI2 in the future.

Share this post


Link to post
Share on other sites
Hello, I need help, I want to put on a mission for a database for players with the uid, I just need to keep (position, inventory, weapon, thirst, hunger and health) and restore item. The mission is survival type. I can indicate any guide or manual on how to do it.

 

I feel my ignorance on this. I hope you can help me.

 

Thank you very much.

 

Note: My English is very bad, I use Google Translate.

Share this post


Link to post
Share on other sites

I don't even get an error in my RPT. Any idea why this isn't firing?

init.sqf

if (isServer) then {    
    diag_log "SERVER SETTING UP";
    //server function for sending stats to client
    fnc_getkills = {
        _who = objectFromNetId (_this select 0);
        _uid = _this select 1;
        _player_name = _this select 2;
        _retrieved_id = ["read", [_player_name, "UID"]] call _inidbi;
        diag_log _retrieved_id;
        diag_log "SERVER RUNNING KILL UPDATE";
        //Test for new player
        if (_retrieved_id == false) then {
            diag_log "SERVER SETTING UP DB";
            _deaths= 0;
            _kills= 0;
            _inidbi = ["new", _player_name] call OO_INIDBI;
            ["write", [_player_name, "UID", _uid]] call _inidbi;
            ["write", [_player_name, "deathcount", _deaths]] call _inidbi;
            ["write", [_player_name, "killcount", _kills]] call _inidbi;
        };
        kills = ["read", [_player_name, "killcount"]] call _inidbi;
        (owner _who) publicVariableClient "kills";
    };
    
    fnc_getdeaths = {
        _who = objectFromNetId (_this select 0);
        _uid = _this select 1;
        _player_name = _this select 2;
        _retrieved_id = ["read", [_player_name, "UID"]] call _inidbi;
        //Test for new player
        if (_retrieved_id == false) then {
            _deaths= 0;
            _kills= 0;
            ["write", [_player_name, "UID", _uid]] call _inidbi;
            ["write", [_player_name, "deathcount", _deaths]] call _inidbi;
            ["write", [_player_name, "killcount", _kills]] call _inidbi;
        };
        deaths = ["read", [_player_name, "deathcount"]] call _inidbi;
        (owner _who) publicVariableClient "deaths";
    };
}; 

Any help would be appreciated.

EDIT: This is being ran on a dedicated box btw.

Share this post


Link to post
Share on other sites

my unit just found that inidbi 2 no longer works with ace 3 units that are assigned as medics in ace no longer are one after the first time u join the server dose anyone had this ?  

Share this post


Link to post
Share on other sites

@xdinox

 

I need help, I want to put on a mission for a database for players with the uid, I just need to keep (position, inventory, weapon, thirst, hunger and health) and restore item. The mission is survival type. I can indicate any guide or manual on how to do it.

 

 

My mission already does all of that and more feel free to look at how I have done it

 

https://forums.bistudio.com/topic/186666-zks-lost-mp-survival-mission/

  • Like 1

Share this post


Link to post
Share on other sites

my unit just found that inidbi 2 no longer works with ace 3 units that are assigned as medics in ace no longer are one after the first time u join the server dose anyone had this ?

you could set inidbi2 to apply this to your unit on joining, you would need to find the function for this from ace3, that should solve your problem.....maybe its something that happens with ace3 not inidbi?

Share this post


Link to post
Share on other sites

you could set inidbi2 to apply this to your unit on joining, you would need to find the function for this from ace3, that should solve your problem.....maybe its something that happens with ace3 not inidbi?

Any way you know where to put it in the code I have the Ace 3 function?

Share this post


Link to post
Share on other sites

Any way you know where to put it in the code I have the Ace 3 function?

Im not sure i havent looked at this function myself, i will be digging the functions out for saveing player health with ace3 though so i will have a look...

Edit.

I found this may do the job

this setVariable ["Ace_medical_medicClass", 1];

Edit.

Ok this a bit of guess work as im currently at work.

I think,

0 = no medic class set

1 = general medic (cant rember names)

2 = full medic (cant rember names)

CODE:

//saving script

//this will return 0 as default ie no medic class set - returns 1 or 2 depending if medic class already set

_whatsortofmedic = player getVariable ["Ace_medical_medicClass", 0];

["write", ["MEDIC", "Class", _whatsortofmedic]] call _inidbi;

//loading script

_readmedicclass = ["read", ["MEDIC", "Class", 0]] call _inidbi;

player setVariable ["Ace_medical_medicClass", _readmedicclass];

------------------------------

This may not be accurate and is untested but from what i gather it should work, if your using it on a dedi server for example you will need to look at my previous noob post to be able to set it up server side

Share this post


Link to post
Share on other sites

I'm trying to save an array of various types of entries (strings, numbers, arrays) and am having trouble reading it back from the database. The array saves fine, but when I read it back, I get an error (missing [[ or something similar - I can go into more detail if needed). I've had a read through the thread and can't work out if this is a bug or intended, but for whatever reason, in the read back, my saved array gets messed up. Is there a knack to saving large and complex arrays to INIDB? 

 

Here's an example of the type of array I'm trying to save: 

 

["B_soldier_AAR_F",[4061.65,20587.3,261.261],"James Robinson","WhiteHead_05","Male06ENG","_unit = _this select 0;
removeAllWeapons _unit;
removeAllItems _unit;
removeAllAssignedItems _unit;
removeUniform _unit;
removeVest _unit;
removeBackpack _unit;
removeHeadgear _unit;
removeGoggles _unit;
_unit forceAddUniform 'U_B_CombatUniform_mcam_tshirt';
_unit addItemToUniform 'FirstAidKit';
_unit addItemToUniform '30Rnd_65x39_caseless_mag';
_unit addItemToUniform 'Chemlight_green';
_unit addVest 'V_Chestrig_rgr';
for '_i' from 1 to 5 do {_unit addItemToVest '30Rnd_65x39_caseless_mag';};
_unit addItemToVest '16Rnd_9x21_Mag';
for '_i' from 1 to 2 do {_unit addItemToVest 'HandGrenade';};
for '_i' from 1 to 2 do {_unit addItemToVest 'B_IR_Grenade';};
_unit addItemToVest 'SmokeShell';
_unit addItemToVest 'SmokeShellGreen';
_unit addItemToVest 'Chemlight_green';
_unit addBackpack 'B_Kitbag_rgr_AAR';
_unit addItemToBackpack 'optic_tws_mg';
for '_i' from 1 to 2 do {_unit addItemToBackpack 'bipod_01_F_snd';};
_unit addItemToBackpack 'muzzle_snds_338_sand';
_unit addItemToBackpack 'muzzle_snds_H';
for '_i' from 1 to 2 do {_unit addItemToBackpack '100Rnd_65x39_caseless_mag';};
for '_i' from 1 to 2 do {_unit addItemToBackpack '100Rnd_65x39_caseless_mag_Tracer';};
for '_i' from 1 to 2 do {_unit addItemToBackpack '130Rnd_338_Mag';};
_unit addHeadgear 'H_HelmetB_light';
_unit addWeapon 'arifle_MX_ACO_pointer_F';
_unit addPrimaryWeaponItem 'acc_pointer_IR';
_unit addPrimaryWeaponItem 'optic_Aco';
_unit addWeapon 'hgun_P07_F';
_unit addWeapon 'Rangefinder';
_unit linkItem 'ItemMap';
_unit linkItem 'ItemCompass';
_unit linkItem 'ItemWatch';
_unit linkItem 'ItemRadio';
_unit linkItem 'NVGoggles';
",0,[0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.5]]

Any ideas? My end goal is to get an array containing several of the above arrays to spawn a player's AI group members on mission start. I don't particularly want to have to write each part of the array out and save it separately if I can avoid it.

 

Also, thanks for this brilliant mod!

Share this post


Link to post
Share on other sites

You cant save those functions (ie additem, removeitem), you need to use for example 'get' fuctions

Something like

getPlayeruid player;

profilename;

Then make the variables ie,

_myuid = getPlayeruid player;

_myprofilename = profilename;

Then make them into an array ie,

_myplayerarray = [_myuid,_myprofilename];

Then save your array to inidbi2 ie,

["write", ["MYINFO", "Myplayer", _myplayerarray]] call _inidbi2;

Theres onviously a little more to it, this is just a quick example....

Edit

Didnt read your question fully,

Using my example it should work something like ie,

_readmyarray = ["read", ["MYINFO", "myplayer", ""]] call _inidbi2;

_myuid = _readmyarray select 0;

_myprofilename = _readmyarray select 1;

Hopefully this makes sence....

  • Like 1

Share this post


Link to post
Share on other sites

You cant save those functions (ie additem, removeitem), you need to use for example 'get' fuctions

Something like

getPlayeruid player;

profilename;

Then make the variables ie,

_myuid = getPlayeruid player;

_myprofilename = profilename;

Then make them into an array ie,

_myplayerarray = [_myuid,_myprofilename];

Then save your array to inidbi2 ie,

["write", ["MYINFO", "Myplayer", _myplayerarray]] call _inidbi2;

Theres onviously a little more to it, this is just a quick example....

Edit

Didnt read your question fully,

Using my example it should work something like ie,

_readmyarray = ["read", ["MYINFO", "myplayer", ""]] call _inidbi2;

_myuid = _readmyarray select 0;

_myprofilename = _readmyarray select 1;

Hopefully this makes sence....

Thank you for the help. I'm happy with saving and retrieving the data, my question was more about getting the 'read' data to be exactly the same as the 'save' data when using complex arrays of strings containing strings. Something happens along the way that changes it, it seems, and can stop the data working properly when imported back into Arma. 

 

Specifically, I'm finding it difficult to read complex arrays saved by iniDBI2 as the saving process seems to play havoc with parenthesis. Aside from encoding all data (which makes it hard to save much data due to reaching the 8k limit quickly) is there a way to stop iniDBI2 messing with parenthesis in arrays of strings? 

 

(And ignore the loadout string in my previous post - I found a better way to export loadouts). 

  • Like 1

Share this post


Link to post
Share on other sites

Hi code34! Are you going to release iniDBI2 x64 edition?

Share this post


Link to post
Share on other sites

I receive these strange warnings but I don't use function getSeparator:

Warning: 1218 ms spent in callExtension calling name: "inidbi2", function: "getseparator"

This occurs with x86 version. Haven't tested with x64 version yet.

Share this post


Link to post
Share on other sites

Hello, i need some help. I've copied scripts that Persian MO pasted on page 5, and modified them a little bit to my needs. The problem is... that the crates save the equipment but for example if i put a weapon in one crate it appears in the second one too. I want them to work separately, that means if i put something in one of them it won't appear in the other one.

 

Ammobox init:

null = [this] execVM "load_box.sqf";null = [this] execVM "save_box.sqf"

 

 

 

load_box.sqf

_object = _this select 0;


_inidbi = ["new", "crates"] call OO_INIDBI;



_items = ["read", ["box", "locker"]] call _inidbi;

clearItemCargoGlobal _object;
clearWeaponCargoGlobal _object;
clearBackpackCargoGlobal _object;
clearMagazineCargoGlobal _object;



if(!(_items isEqualTo [])) then
		{
			{
				_subArr = _items select _forEachIndex;
				_weps = _subArr select 0;
				_wepsCount = _subArr select 1;
				_mags = _subArr select 2;
				_magsCount = _subArr select 3;
				_itemss = _subArr select 4;
				_itemsCount = _subArr select 5;
				_backpacks = _subArr select 6;
				_backpacksCount = _subArr select 7;
				{
					_object addWeaponCargoGlobal[_x,_wepsCount select _forEachIndex];
				} forEach _weps;
				{
					_object addMagazineCargoGlobal[_x,_magsCount select _forEachIndex];
				} forEach _mags;
				{
					_object addItemCargoGlobal[_x,_itemsCount select _forEachIndex];
				} forEach _itemss;
				{
					_object addBackpackCargoGlobal[_x,_backpacksCount select _forEachIndex];
				} forEach _backpacks;
			} forEach _items;	
};
hint "Loading completed";

 

 

 

save_box.sqf

_object = _this select 0;


Sleep 1;
while {true} do {
Sleep 5;

_saveArray = [];
_guns = getWeaponCargo _object;
_mags = getMagazineCargo _object;
_items = getItemCargo _object;
_backpacks = getBackpackCargo _object;
_subArray = _guns + _mags + _items + _backpacks;
_saveArray set [count _saveArray,_subArray];

_inidbi = ["new", "crates"] call OO_INIDBI;


_bool=["write", ["box", "locker", _saveArray]] call _inidbi;


hint format ["Status: %1",_bool];
};

 

Edit:

Never mind i found alternative.

https://forums.bistudio.com/topic/173785-save-ammobox-contents-after-restart/

 

Share this post


Link to post
Share on other sites

I'm working on a persistent mission and have a question.

 

Is it possible to save the data including contents of a dynamically spawned vehicle?

 

I was thinking I could trigger inidb2 to save the position and contents by using the "PUT" and "TAKE" or maybe the "getIn" EV's. But reading through the forums and wiki it doesn't look like spawned vehicles generate their own uid. So, I'm unsure how to actually get  the database to save the vehicle data.

 

In a nutshell, if a player comes across or captures a vehicle, I want inidbi2 to recognize that the vehicle should become persistent at that time. I definitely don't want all spawned vehicles to be persistent.

 

I think I can get this, I just don't have a great knowledge of all the possible EV's and script commands that may work to accomplish this.

 

Thank you,

Fire

Share this post


Link to post
Share on other sites

Hi there,

 

I'm using TADST and INDBI2. I just tried with the new x64 server, and the INDBI functions seems to have an issue.

Here what I got in the rpt:

_items = ["read", ["box", >
 8:53:19   Error Undefined variable in expression: oo_inidbi
 8:53:19 File mpmissions\__CUR_MP.Chernarus\load_box.sqf, line 3
 8:53:19 Error in expression <(_object);
_inidbi = ["new", _nom] call OO_INIDBI;

In spoiler my sqf:

Spoiler

_object = _this select 0;
_nom = str (_object);
_inidbi = ["new", _nom] call OO_INIDBI;

_items = ["read", ["box", "locker"]] call _inidbi;

//clearItemCargoGlobal _object;
//clearWeaponCargoGlobal _object;
//clearBackpackCargoGlobal _object;
//clearMagazineCargoGlobal _object;

if(!(_items isEqualTo [])) then
{
{
_subArr = _items select _forEachIndex;
_weps = _subArr select 0;
_wepsCount = _subArr select 1;
_mags = _subArr select 2;
_magsCount = _subArr select 3;
_itemss = _subArr select 4;
_itemsCount = _subArr select 5;
_backpacks = _subArr select 6;
_backpacksCount = _subArr select 7;
{
_object addWeaponCargoGlobal[_x,_wepsCount select _forEachIndex];
} forEach _weps;
{
_object addMagazineCargoGlobal[_x,_magsCount select _forEachIndex];
} forEach _mags;
{
_object addItemCargoGlobal[_x,_itemsCount select _forEachIndex];
} forEach _itemss;
{
_object addBackpackCargoGlobal[_x,_backpacksCount select _forEachIndex];
} forEach _backpacks;
} forEach _items; 
};
//hint format ["test:%1", _object];
hint "Loading completed";

 

When I'm using the armaServer x32, there is no issue and the DB is working without issue.

Share this post


Link to post
Share on other sites
1 hour ago, zuzul said:

When I'm using the armaServer x32, there is no issue and the DB is working without issue.

 

Very easy fix zuzul. 

 

On ‎17‎/‎12‎/‎2016 at 4:54 PM, code34 said:

hi,

 

you can find the inidbi2 64bits dll version at this place (i dont put for the moment in a package as it for dev release)

 

https://www.dropbox.com/s/pb2um6iynff37jl/inidbi2_x64.dll?dl=0

 

please give me a feedback

 

Drop the inidb2_x64.dll into your inidb2 folder.

  • Like 1

Share this post


Link to post
Share on other sites
26 minutes ago, kremator said:

 

Very easy fix zuzul. 

 

 

Drop the inidb2_x64.dll into your inidb2 folder.

Many thanks and sorry for not having checked the previous posts. 

I'll give it a try today and provide feedbacks.

 

Edit: it works perfectly, many thanks.

This community is definitivly awesome.

Share this post


Link to post
Share on other sites

I have the following problem. I'm trying to save a players position and loadout in a DB and then give it to them.

 

saving:

_section = getPlayerUID player;
_pos = position player;
_loadout = getUnitLoadout player;

["write",[str _section, "position", _pos]] call database;
["write",[str _section, "loadout", _loadout]] call database;

and loading:

	_loadout = ["read",[str _section, "loadout",[]]] call database;
	_position = ["read",[str _section, "position",[]]] call database;
	player setUnitLoadout [_loadout, false];
	player setPos _position;

 

However on testing this it gives me an error " variable _data not defined. File \inidbi2\oo_inidbi.sqf [BIS_fnc_inidbi2], line 561

 

Any help would be greatly appreciated!

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

×