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

Sorry for bumping up this old topic but, just for the sake of making it easier for the people who google for "iniDB", here is a link to the newer version by code34.:

http://www.armaholic.com/page.php?id=23340

ps.: Best not reply here, as this thread is really kinda outdated. So let it rest.

Share this post


Link to post
Share on other sites

okay so im trying to make an variable called Cash save over restart and shit with inidb and this is what im trying to do

[GetPlayerUID player,"RPP_Cash",Cash, "SCALAR"] call inidb_read; //this one is reading the Cash var but it wont read it and set it to what i had before the restart happend :(


[GetPlayerUID player,"RPP_Cash", "Cash", Cash] call iniDB_write; //this is what i use for writing it to the db stuff, and this one works just fine

Share this post


Link to post
Share on other sites
okay so im trying to make an variable called Cash save over restart and shit with inidb and this is what im trying to do

[GetPlayerUID player,"RPP_Cash",Cash, "SCALAR"] call inidb_read; //this one is reading the Cash var but it wont read it and set it to what i had before the restart happend :(


[GetPlayerUID player,"RPP_Cash", "Cash", Cash] call iniDB_write; //this is what i use for writing it to the db stuff, and this one works just fine

So.. something like this?

_player = getAssignedCuratorUnit _x;
		if (_x == _player) then {} else {
			_name = name _x;
			_name_money = _name + "_money";
			_pub_name_money = str (_name_money); 
			_Profile = format["%1", getPlayerUID _x]; 
			_name_UID = _name + "_" + _Profile;
			_money = missionNamespace getVariable _pub_name_money;
			_exist = _name_UID call iniDB_exists;
			if (isNil {_money}) then {
				if (_exist) then { _money = [_name_UID, _Profile, "Money", "SCALAR"] call iniDB_read;} else {
					_money = 100;
				};
				[_name_UID, _Profile, "Name", _name] call iniDB_write;
				[_name_UID, _Profile, "Money", _money] call iniDB_write;
				_clientID = owner _x;
				missionNamespace setVariable [_pub_name_money, _money];
				_clientID publicVariableClient format ["%1", _pub_name_money];
			} else {
				if (_money > 999999) then {
					_offence = "Money over 1 Million";
					["Report", _Profile, "Name", _name] call iniDB_write;
					["Report", _Profile, "Different_Money", _money] call iniDB_write;
					["Report", _Profile, "Offence", _offence] call iniDB_write;
				};
				[_name_UID, _Profile, "Name", _name] call iniDB_write;
				[_name_UID, _Profile, "Money", _money] call iniDB_write;
				missionNamespace setVariable [_pub_name_money, _money];
				_clientID = owner _x;
				_clientID publicVariableClient format ["%1", _pub_name_money];
				if (isNil {adminOnline}) then {adminOnline = false;};
				if (isNil {admin1Online}) then {admin1Online = false;};
				if (isNil {admin2Online}) then {admin2Online = false;};
				if (adminOnline) then { missionNamespace setVariable [_pub_name_money, _money]; AdminID publicVariableClient format ["%1", _pub_name_money];} else {adminOnline = false;};
				if (admin1Online) then { missionNamespace setVariable [_pub_name_money, _money]; AdminID1 publicVariableClient format ["%1", _pub_name_money];} else {adminOnline1 = false;};
				if (admin2Online) then { missionNamespace setVariable [_pub_name_money, _money]; AdminID2 publicVariableClient format ["%1", _pub_name_money];} else {adminOnline2 = false;};
			};
		};
	}forEach playableUnits;
};
};

Your much better off with mysql its alot easier to work with..

or use our prebuilt system.. http://www.armaholic.com/page.php?id=27734 its not updated practically but yeah... it works see if you can detangle our mess of hell

Edited by Jetfox

Share this post


Link to post
Share on other sites

Is there a tut for setting a custom load out for my Admins after they die and respawn? I want to be able to give them extra gear as they spend most of their time putting out player fires than playing and need to reward them for the efforts... I am using the inidb persistent data base, and wondered if there was a way to call a subscript when a player is killed and respawns. I think it would be like this:

on player spawn

Check player guid

if statement GUID is in list

load guid xxx.ini(player loadout)

else if,

load standard loadout

I am guessing that there would be a ton more to this, but I am just trying to get the idea across.

The other option is to go to a MySQL, but I am running my own dedicated box and don't know how to move it over to a MySQL service...

Thanks for the help...

Matt!

Share this post


Link to post
Share on other sites

OK, I admit I'm a noob with sqf files and coding and I know I'm probably missing something right in front of my face.

I am running a dedicated ArmA 3 server and running the mission "Hired Guns" which needs inidb to save player progress. However, I am running into a problem where player progress and loadout are not being restored after reconnecting or restarting the server.

I followed the mod instructions in Steam Workshop for "Hired Guns"

And followed the very brief instructions for inidb from this forum.

When I'm connected to the server I can see my loadout being written the [pid].ini file and any mission progress being written to "missioninprogress.ini".

Any time I reconnect to server or restart the server my player progress is wiped clean.

I really appreciate any feedback.

Share this post


Link to post
Share on other sites

This works great! However it strips the player of weapons and clothing items on first login. is that by design or have I gone horribly wrong somewhere

 

InitServer.sqf

call compile preProcessFile "\inidbi\init.sqf";
call compile preProcessFile "Arma3functions.sqf";
call compile preProcessFile "IniDB\LoadPlayer.sqf";

DeleteItemPlayer.sqf

removeAllWeapons Player;
removeAllItems Player;
removeAllAssignedItems Player;
removeUniform Player;
removeVest Player;
removeBackpack Player;
removeHeadgear Player;
removeGoggles Player;
[Player] call abc_LoadplayerPosServer;

LoadPlayer.sqf

abc_LoadplayerPos = {

private ["_loadpos"];
_loadpos = _this select 0;
_Profile = format["%1", getPlayerUID _loadpos];


//============	Load Stats
execVM "IniDB\DeleteItemPlayer.sqf";
//PLAYER
playerPos = [_profile, "playerData", "location", "ARRAY"] call iniDB_read;
playerHealth = [_profile, "playerData", "health", "SCALAR"] call iniDB_read;
playerOxygen = [_profile, "playerData", "oxygen", "SCALAR"] call iniDB_read;

//INVENTORY
playerBackpack = [_profile, "playerData", "backpack", "STRING"] call iniDB_read;
playerBackpackGear = [_profile, "playerData", "backpackGear", "ARRAY"] call iniDB_read;
playerVest = [_profile, "playerData", "vest", "STRING"] call iniDB_read;
playerVestGear = [_profile, "playerData", "vestGear", "ARRAY"] call iniDB_read;
playerUniform = [_profile, "playerData", "uniform", "STRING"] call iniDB_read;
playerUniformGear = [_profile, "playerData", "uniformGear", "ARRAY"] call iniDB_read;
playerGadgets = [_profile, "playerData", "gadgets", "ARRAY"] call iniDB_read;
playerHeadgear = [_profile, "playerData", "headgear", "STRING"] call iniDB_read;
playerGoggles = [_profile, "playerData", "goggles", "STRING"] call iniDB_read;
playerWep = [_profile, "playerData", "weapons", "ARRAY"] call iniDB_read;
playerPrimWepAttach = [_profile, "playerData", "primWeaponAttachments", "ARRAY"] call iniDB_read;
playerSecWepAttach = [_profile, "playerData", "secWeaponAttachments", "ARRAY"]  call iniDB_read;
playerMagazines = [_profile, "playerData", "magazines", "ARRAY"] call iniDB_read;
systemChat "Чтение ÑохранениÑ...";
};

if(isServer) then {
[] execVM "IniDB\SavePlayer.sqf";};

SavePlayer.sqf

if(isServer) then {
while{true} do {
	{
		if(isPlayer _x) then {
			sleep 5;
					//============	Save Stats
					_Profile = format["%1", getPlayerUID _x];
					//PLAYER
					[_profile, "playerData", "name", name _x] call iniDB_write;
					[_profile, "playerData", "location", position _x] call iniDB_write;
					[_profile, "playerData", "oxygen", getOxygenRemaining _x] call iniDB_write;
					[_profile, "playerData", "health", damage _x] call iniDB_write;
					//INVENTORY
					[_profile, "playerData", "weapons", weapons _x] call iniDB_write;
					[_profile, "playerData", "primWeaponAttachments", primaryWeaponItems _x] call iniDB_write;
					[_profile, "playerData", "secWeaponAttachments", secondaryWeaponItems _x] call iniDB_write;
					[_profile, "playerData", "magazines", magazinesAmmoFull _x] call iniDB_write;
					[_profile, "playerData", "backpack", backpack _x] call iniDB_write;
					[_profile, "playerData", "backpackGear", backpackItems _x] call iniDB_write;	
					[_profile, "playerData", "vest", vest _x] call iniDB_write;		
					[_profile, "playerData", "vestGear", vestItems _x] call iniDB_write;
					[_profile, "playerData", "uniform", uniform _x] call iniDB_write;
					[_profile, "playerData", "uniformGear", uniformItems _x] call iniDB_write;
					[_profile, "playerData", "gadgets", assignedItems _x] call iniDB_write;
					[_profile, "playerData", "headgear", headgear _x] call iniDB_write;
					[_profile, "playerData", "goggles", goggles _x] call iniDB_write;
					systemChat "Сохранение...";
			};	
		
		} forEach allUnits;

	}
	
};

Arma3functions.sqf

// Do not edit this file!
// This file may only be edited by Engima's ASCOM Editor!
//
// <ASCOM version="1">
// <Prefix>abc_</Prefix>
// <Functions>
// <Function Name="LoadplayerPos" Params="loadpos" Ret="false" A="false" C="false" S="true" O="false" OC="false" P="false" />
// <Function Name="LoadPlayerWeapon" Params="weapon" Ret="false" A="false" C="false" S="true" O="false" OC="false" P="false" />
// </Functions>
// </ASCOM>

ASCOM_ClientID = 0;
ASCOM_CallID = 0;
ASCOM_LastCallID = 0;
ASCOM_LockCallID = 0;

"abc_LoadplayerPosEventArgs" addPublicVariableEventHandler {
    private ["_array"];

    _array = _this select 1;

    _array spawn {
        if ((_this select 0 == "A") || (_this select 0 == "C" && !isDedicated)) then {
            (_this select 1) call abc_LoadplayerPos;
        };

        if (_this select 0 == "S" && isServer) then {
            (_this select 1) call abc_LoadplayerPos;
        };
    };
};

abc_LoadplayerPosServer = {
    if (isNil "_this") then { _this = []; };
    if (isServer) then {
        _this call abc_LoadplayerPos;
    }
    else {
        abc_LoadplayerPosEventArgs = ["S", _this];
        publicVariable "abc_LoadplayerPosEventArgs";
        abc_LoadplayerPosEventArgs = [];
    };
};


"abc_LoadPlayerWeaponEventArgs" addPublicVariableEventHandler {
    private ["_array"];

    _array = _this select 1;

    _array spawn {
        if ((_this select 0 == "A") || (_this select 0 == "C" && !isDedicated)) then {
            (_this select 1) call abc_LoadPlayerWeapon;
        };

        if (_this select 0 == "S" && isServer) then {
            (_this select 1) call abc_LoadPlayerWeapon;
        };
    };
};

abc_LoadPlayerWeaponServer = {
    if (isNil "_this") then { _this = []; };
    if (isServer) then {
        _this call abc_LoadPlayerWeapon;
    }
    else {
        abc_LoadPlayerWeaponEventArgs = ["S", _this];
        publicVariable "abc_LoadPlayerWeaponEventArgs";
        abc_LoadPlayerWeaponEventArgs = [];
    };
};



if (isServer) then {
    "ASCOM_AskForClientID" addPublicVariableEventHandler {
        private ["_unit"];

        _unit = _this select 1;
        ASCOM_AskForClientID = [];
        ASCOM_LastCallID = ASCOM_LastCallID + 1;
        ASCOM_ClientIDResponse = [_unit, ASCOM_LastCallID];
        publicVariable "ASCOM_ClientIDResponse";
    };

    ASCOM_ServerInitialized = true;
    publicVariable "ASCOM_ServerInitialized";
    ASCOM_Initialized = true;
}
else {
    "ASCOM_ClientIDResponse" addPublicVariableEventHandler {
        private ["_array"];

        _array = _this select 1;
        ASCOM_ClientIDResponse = [];

        if (player == (_array select 0)) then {
            ASCOM_ClientID = _array select 1;
            ASCOM_Initialized = true;
        };
    };

    waitUntil {!isNull player};
    ASCOM_AskForClientID = player;
    publicVariable "ASCOM_AskForClientID";
};
 
The entry goes on, but no reading, after the release of the remains of the corpse? :(

Share this post


Link to post
Share on other sites

Im quiet OK i scripting but just dont have the time at the moment.

Is there a mission somewhere that uses this for Ace3 compatible player persistence?

Share this post


Link to post
Share on other sites

So i have a BMR server with TADST and im trying to use IniDB to save my server once i shut down my pc overnight and its not working.Could someone tell me what to do inorder for it to work.

Share this post


Link to post
Share on other sites

With the release of the x64 executable for ArmA 3, do we need an update for the IniDB aswell?

Share this post


Link to post
Share on other sites
On 3/22/2017 at 2:20 AM, Atlas1205 said:

\iniDB\init.sqf not found?????

Paste your code here.

Note in should only be the server compiling the inidb for example in init.sqf.

if (isServer) then {
	call compile preProcessFile "\iniDB\init.sqf";
};

The Client shouldn't have @iniDB nor should it call compile it.

Usage as per stated here:

On 3/16/2013 at 7:15 AM, SicSemperTyrannis said:

_unit = _this;
_puid = getPlayerUID _unit;

if(!isServer) exitWith {};

if(_puid == "_SP_PLAYER_" || _puid == "") exitWith {};

// Allow users with multiple profiles to make new profiles and have new lives
// We want to use CRC hashes for the name because some people have spaces, weird characters or some other stuff so it's just better this way.
_profileName = _unit getVariable["profileName", ""];

if(_profileName == "") exitWith {};

_unitFileName = format["%1_%2", _puid, (_profileName call iniDB_CRC32)];

// We will save to the same file, but use different sections for each side
// We don't want cop uniforms/pos/etc saving over to insurgent or civilian sides
// This will mean persistent data will carry over _per occupation_, pretty neat right?
_sectionTitle = format["%1", side _unit];

// Actually save global data
[_unitFileName, _sectionTitle, "pos", position _unit] call iniDB_write;
[_unitFileName, _sectionTitle, "loadout", ([_unit] call getLoadout)] call iniDB_write;

 

 

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  

×