NeoArmageddon 958 Posted June 15, 2014 Aloha, one of the most annoying things in A3 multiplayer are the parameters. Especially in restart heavy missions changing the params every new round again is annoying. I wrote this little script (originally for co10 Escape). It is able to save parameters and restore them at the next missionstart: fn_parameterInit.sqf //###Parameter Storage and Loading by NeoArmageddon.### //Load default params for SP && Editor if (isNil "paramsArray") then { private ["_c", "_i", "_paramName"]; paramsArray=[]; if (isClass (missionConfigFile/"Params")) then { _c=count (missionConfigFile/"Params"); for [ {_i=0}, {_i<_c}, {_i=_i+1} ] do { _paramName = (configName ((missionConfigFile >> "Params") select _i)); paramsArray=paramsArray+[ getNumber (missionConfigFile >> "Params" >> _paramName >> "default") ]; }; }; }; AT_fnc_ParamsToVar = { //Compile params into real variables: private["_c","_paramName"]; _c=count (missionConfigFile/"Params"); for [ {_i=0}, {_i<_c}, {_i=_i+1} ] do { _paramName = (configName ((missionConfigFile >> "Params") select _i)); call compile format["%1 = %2;publicVariable '%1';",_paramName,paramsArray select _i]; }; }; //Compile Params into Variables call AT_fnc_ParamsToVar; private["_paramLoading","_params"]; _paramLoading = Param_Loadparams; switch (_paramLoading) do { case 0: { uiNamespace setVariable ["AT_SavedParams", paramsArray]; }; case 1: { //Load params if existing in UINamespace _params = uiNamespace getVariable ["AT_SavedParams",[]]; if(count(_params)==0 || count(_params)!=count(paramsArray)) then { uiNamespace setVariable ["AT_SavedParams", paramsArray]; } else { paramsArray = _params; publicvariable "paramsArray"; }; }; case 2: { //Use paramsArray, do nothing }; }; //Reompile Params into Variables because they may have changed. call AT_fnc_ParamsToVar; AT_ParamsParsed = true; publicVariable "AT_ParamsParsed"; Features: Store and load parameters Set manual parameter mode to disable loading/saving Puts default settings into paramsArray in singleplayer and editor Compiles all values into the param name as a variable (there is a BIS function that does something similar), so you don't have to edit your scripts, if you delete or add new parameters. Restarting the server will reset the settings. Parameter example: class Params { class Param_Loadparams { title = "Parameter Loading"; values[] = {0, 1, 2}; texts[] = {"Use below and save", "Load existing (Use below if not found)", "Use below without save"}; default = 1; }; class Param_TimeOfDay { title="Time Of Day"; values[]={0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24}; texts[]={"00:00","01:00","02:00","03:00","04:00","05:00","06:00","07:00","08:00","09:00","10:00","11:00","12:00","13:00","14:00","15:00","16:00","17:00","18:00","19:00","20:00","21:00","22:00","23:00","Random"}; default = 24; }; class Param_Weather { title = "Weather"; //--- ToDo: Localize values[] = {0,1,2,3,4,5}; texts[] = {"Clear","Sunny","Cloudy","Foggy","Stormy","Random"}; //--- ToDo: Localize default = 3; }; }; The example above will be compiled into the variables "Param_TimeOfDay = 24" and "Param_Weather=3" of nothing is changed or in SP. If something was changed, it will be stored for next missionstart and applied automatically. Installation: But the fn_parameterInit.sqf code in a function file or another sqf file and run it at missionstart on the server. The Param_Loadparams parameter must be present in your description.ext param-class: class Param_Loadparams { title = "Parameter Loading"; values[] = {0, 1, 2}; texts[] = {"Use below and save", "Load existing (Use below if not found)", "Use below without save"}; default = 1; }; Calling as function: if(isserver) then { call AT_fnc_parameterInit; }; Calling as script: if(isserver) then { call compile preprocessfilelinenumber "fn_parameterInit.sqf"; }; Credits: Engima for the SP&Editor loading. Scruffy, Maike, Freshman, Joshi and Darcy for testing. Name for having no BAS. And here is a little script that can post all parameters to the ingamebriefing: //Parameters in Briefing script by NeoArmageddon private["_paramsArray","_settings"]; _paramsArray = _this; _settings = "Parameters:<br/>"; waituntil{!isNull player || isServer}; if(!isNull player) then { if (isClass (missionConfigFile/"Params")) then { _c=count (missionConfigFile/"Params"); for [ {_i=0}, {_i<_c}, {_i=_i+1} ] do { _paramName = (configName ((missionConfigFile >> "Params") select _i)); _name = getText (missionConfigFile >> "Params" >> _paramName >> "title"); _value = _paramsArray select _i; _index = (getArray (missionConfigFile >> "Params" >> _paramName >> "values")) find _value; _valueName = (getArray (missionConfigFile >> "Params" >> _paramName >> "texts")) select _index; _settings = _settings + format["%1 : %2 (%3)<br/>",_name,_valueName,_value]; }; }; player createDiaryRecord ["Diary", ["Settings", _settings]]; } else { hint format["Player is null"]; }; Share this post Link to post Share on other sites