Jump to content
kibaBG

Saving tasks state in MP with missionProfileNamespace ?

Recommended Posts

Hi, I wonder if missionProfileNamespace (or profileNamespace )can be used to save mission tasks in MP? Previously I have save markers using the profileNamespace to store markers like this: 

 

//save markers to user profile, server side
_mapMarkers = allMapMarkers select {!('_USER_DEFINED' in _x)};
_mrkRed = _mapMarkers select {(markerColor _x == "colorOPFOR")};
profileNamespace setVariable ["NeolibNapfMarkers", _mrkRed];

//load markers from user profile, server side
_mrkRed = profileNamespace getVariable ["NeolibNapfMarkers", []];
{_x setMarkerColor "colorOPFOR"} forEach _mrkRed;

//delete save, server side 
profileNamespace setVariable ["NeolibNapfMarkers", nil];

But it would be awesome if tasks can be saved too ... :hyper:

Share this post


Link to post
Share on other sites

Should be possible.

All task information ( Task Framework tasks ) have their info stored in a set of missionNamespace variables "@taskID.INDEX" .

See...

\a3\functions_f\tasks\defines.inc  ( for handy macros and INDEX values )

\a3\functions_f\tasks\fn_createTask.sqf  ( all this func does is processes params and passes it to below func )

\a3\functions_f\tasks\fn_setTask.sqf  ( task information is processed here, which then calls the below based on task owners )  <<This one should give you most of what you need to know

\a3\functions_f\tasks\fn_setTaskLocal.sqf  ( this is where each TASK is actually created per client/task owner )

 

So should be something like using missionNamespace vars to collect tasks info, save it off to profile, on mission reload check for saved tasks, gather info from profile and pass them back through taskCreate. Most likely need a few tweaks like making sure any parent tasks are handled first, any objects destination/task owner etc are saved and restored as objectVar's etc.

 

Dont expect the below to work, its just some rough code to get the point across...

Spoiler

//SAVE

#include "\a3\functions_f\tasks\defines.inc"

if !( isServer ) exitWith {};

_tasks = allVariables missionNamespace select{ _x select[ 0, 1 ] == "@" && { _x select[ count _x -2, 2 ] == ".1" } };
{
	_taskID = missionNamespace getVariable[ _x, "" ];
	if ( !isNil "_taskID" && { _taskID call BIS_fnc_taskExists } ) then {
		_tasks set[ _forEachIndex,			
			[
				GET_DATA( _taskID, OWNERS ),
				[
					GET_DATA( _taskID, ID ),
					GET_DATA( _taskID, PARENT )
				], 
				[
					GET_DATA( _taskID, DESCRIPTION ),
					GET_DATA( _taskID, TITLE ),
					GET_DATA( _taskID, MARKER )
				], 
				GET_DATA( _taskID, DESTINATION ),
				GET_DATA( _taskID, STATE ),
				GET_DATA( _taskID, PRIORITY ),
				false, //Notification state is not saved			
				GET_DATA( _taskID, TYPE ),
				GET_DATA( _taskID, CORE )
			]
		];
	};
}forEach _tasks;

missionProfileNamespace setVariable[ "SavedTasks", _tasks ];




//RESTORE

if !( isServer ) exitWith {};

_savedTasks = missionProfileNamespace getVariable "SavedTasks";

if !( isNil "_savedTasks" ) then {
	{
		_x call BIS_fnc_taskCreate;
	}forEach _savedTasks;
};

 

 

  • 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

×