Jump to content
jo spanner

Saving data, transferring between missions

Recommended Posts

Hi,

I am running an online 'campaign' of sorts.

I'm trying to create a system where the contents of player inventories and the contents of a box can be transferred between missions. The idea is that my players, once back at base (or at some other arbitrary time) can have their contents and the contents of their storage saved, so that I can transfer this to another mission.

I have tried inidbi2, and managed to get player inventory working as expected. This looked like a good solution.

However, the box contents can exceed the apparent 8kb file limit, so that's out.

I am now looking at the profileNameSpace, but is that tied to a specific mission? IE, can I access that data between different missions? The contents are not human readable.

Share this post


Link to post
Share on other sites
On 5/2/2020 at 12:57 AM, jo spanner said:

I am now looking at the profileNameSpace, but is that tied to a specific mission?

No, as the name says its tied to the profile.

On 5/2/2020 at 12:57 AM, jo spanner said:

IE, can I access that data between different missions?

Yes as long as the profile isn't changed.

On 5/2/2020 at 12:57 AM, jo spanner said:

The contents are not human readable.

They are just variables. arrays, strings, numbers...

Share this post


Link to post
Share on other sites

pretty simple, have an file that would be called say 'serverID.sqf' inside that you'd have something like.

 

serverID = "MYSERVERID"; //example - serverID = "PHAT"
publicVariable "serverID";

Here is a snippet of a gamemode i made years ago that did pretty much exactly what you're after

 

//loadAccount.sqf


["NODE_Var_lvl"] call fn_LoadStat;
["NODE_Var_XP"] call fn_LoadStat;
["NODE_fnc_faction"] call fn_LoadStat;
["NODE_side"] call fn_LoadStat;
["NODE_fnc_class"] call fn_LoadStat;
["NODE_SETUP_COMPLETE"] call fn_LoadStat;
call NODE_fnc_gearArray;
_gearFnc = NODE_fnc_gear select NODE_Var_lvl;
player setUnitLoadout  _gearFnc;
call setupCheck;
statsLoaded = 1;
//savefuncs.sqf

fn_SaveStat =
{
	_varName = _this select 0;
	_varValue = _this select 1;
	profileNameSpace setVariable [_varName + serverID,_varValue];
};

fn_LoadStat =
{
	_varName = _this select 0;
	_varValue = profileNameSpace getVariable (_varName + serverID);
	if(isNil "_varValue") exitWith {};
	[_varName,_varValue] call fn_SetStat;
};

//===========================================================================
//ADD VARIABLES TO THIS ARRAY THAT NEED SPECIAL SCRIPTING TO LOAD
specialVarLoads =
[
	"NODE_Var_lvl",
	"NODE_Var_XP",
	"NODE_fnc_faction",
	"NODE_side",
	"NODE_fnc_class",
	"NODE_SETUP_COMPLETE"
];

//THIS FUNCTIONS HANDLES HOW STATS ARE LOADED
fn_SetStat =
{
	_varName = _this select 0;
	_varValue = _this select 1;
	if(isNil '_varValue') exitWith {};
	if(_varName in specialVarLoads) then
	{
		if(_varName == 'NODE_Var_lvl') then {NODE_Var_lvl = _varValue};
		if(_varName == 'NODE_Var_XP') then {NODE_Var_XP = _varValue};
		if(_varName == 'NODE_fnc_faction') then {NODE_fnc_faction = _varValue};
		if(_varName == 'NODE_side') then {NODE_side = _varValue};
		if(_varName == 'NODE_fnc_class') then {NODE_fnc_class = _varValue};
		if(_varName == 'NODE_SETUP_COMPLETE') then {NODE_SETUP_COMPLETE = _varValue};
	}
	else
	{
		call compile format ["%1 = %2",_varName,_varValue];
	};
};

//==================================================================================================================================================================================================
saveFuncsLoaded = true;
//saveloop.sqf

waitUntil {!isNil "statsLoaded"};
while {true} do
{
	["NODE_Var_XP", NODE_Var_XP] call fn_SaveStat;
	sleep 1;
	["NODE_Var_lvl", NODE_Var_lvl] call fn_SaveStat;

};

 

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

×