Saving more than one array on profilenamespace

  1. 6 years ago

    Hi, im using function to save an array of markers and in second instance an array of map objects to ProfileNameSpace with function ALiVE_fnc_ProfileNameSpaceLoad/Save. I made it with different scripts executed on mission start. Both work separately but if i exec both have an script error when i check if second variable exists.

    Thats the way i used to exec scripts via initserver.sqf.

    -_cache_spawn create boxes on array of markers, if markers are not defined in profile name space it defines. When a box is destroyed, marker is deleted of array and save to profilename space. Next time mission starts only create box at markers array without markers where you destroyed a cache.

    -_ant_task select antennas of a classname on map, save to an array and when you destroy one of this, eventhandler deletes from this array an pass to a destroyed antennas array. Next time mission start, script destroy antennas of this array at mission start.

    _cache_spawn = execVM "scripts\cache.sqf";
    waitUntil {scriptDone _cache_spawn};
    
    _ant_task = execVM "scripts\ant.sqf";
    waitUntil {scriptDone _ant_task};

    Both scripts works perfect separately and both script works if i call it first than the other.

    _cache_spawn, this the way i check if array exist at profilenamespace and if not define it.

    cacheMkr = "cacheMkr" call ALiVE_fnc_ProfileNameSpaceLoad;  
    
    sleep 10;
    
    if !(cacheMkr isEqualType []) then { 
    
    cacheMkr = [
    	"cache_mkr_1",
    	"cache_mkr_2",
    	"cache_mkr_3",
    	"cache_mkr_4",
    	"cache_mkr_5",
    	"cache_mkr_6",
    	"cache_mkr_7",
    	"cache_Mkr_8"	
    		
    	];
    	
    ["cacheMkr", cacheMkr] call ALiVE_fnc_ProfileNameSpaceSave;
    
    };    

    _ant_task, this the way i check if array exist at profilenamespace and if not define it.

    ant_array = "ant_array" call ALiVE_fnc_ProfileNameSpaceLoad;
    
    sleep 10;
    
    if !(ant_array isEqualType []) then { 
    
    	ant_array = nearestTerrainObjects [center, ["TRANSMITTER"], 9999, false, true];
    	_class = "Land_TTowerBig_1_F","Land_TTowerBig_2_F";
    
    	{ 
    
    			if !(typeOf _x == _class) then {ant_array = ant_array - [_x]}; 
    
    	} foreach ant_array;
    
    	publicVariable "ant_array"; 
    	["ant_array", ant_array] call ALiVE_fnc_ProfileNameSpaceSave;
    
    	{ 		
    		
    			 des_ant_array = [];
    			 publicVariable "des_ant_array";
    			 ["des_ant_array", des_ant_array] call ALiVE_fnc_ProfileNameSpaceSave;
    	
    };
    
    des_ant_array = "des_ant_array" call ALiVE_fnc_ProfileNameSpaceLoad;
    
    
    sleep 10;
    
    	if (count des_ant_array > 0) then {
    	
    	
    			{
    			
    			_x setDamage 1;
    			
    			
    				} foreach des_ant_array;
    		
    		};	
    

    Both scripts have more lines, but i only post code when i check if array exist in profilenamespace because i understand problem is there.

    I know example you give in wiki but i understand this is only for a boolean (true/false) variable, it gives always error for this case:

    _scriptStarted = "ScriptStarted" call ALiVE_fnc_ProfileNameSpaceLoad;
     
    if (isnil "_scriptStarted" || {!_scriptStarted}) then {
        // start script
        ["ScriptStarted", true] call ALiVE_fnc_ProfileNameSpaceSave;
    };
    

    Was difficult to explain this in this post, i wish you can understand and help me.

    Thanks and great job with alive!!

 

or Sign Up to reply!