change root level folder name to framework, update resupply+vehicleflags
tested locally
This commit is contained in:
14
framework/util/fn_addPlayerInfoToArray.sqf
Normal file
14
framework/util/fn_addPlayerInfoToArray.sqf
Normal file
@@ -0,0 +1,14 @@
|
||||
params [["_playerObj", objNull], ["_arrayToModify", [], [[]]]];
|
||||
|
||||
if (isNull _playerObj) exitWith {_arrayToModify};
|
||||
|
||||
{
|
||||
_arrayToModify = [_arrayToModify, _x#0, _x#1] call BIS_fnc_setToPairs;
|
||||
} forEach [
|
||||
["playerName", name _playerObj],
|
||||
["playerUID", getPlayerUID _playerObj],
|
||||
["playerGroup", groupId (group _playerObj)],
|
||||
["playerNetID", [_playerObj] call BIS_fnc_netId]
|
||||
];
|
||||
|
||||
_arrayToModify;
|
||||
1
framework/util/fn_getBattalionCfg.sqf
Normal file
1
framework/util/fn_getBattalionCfg.sqf
Normal file
@@ -0,0 +1 @@
|
||||
(missionConfigFile >> "BattalionInfo")
|
||||
17
framework/util/fn_getNameOfBase.sqf
Normal file
17
framework/util/fn_getNameOfBase.sqf
Normal file
@@ -0,0 +1,17 @@
|
||||
params [["_base", objNull, [objNull]]];
|
||||
if (_base == objNull) exitWith {""};
|
||||
|
||||
// get base name
|
||||
private _baseName = _base getVariable ["name", ""];
|
||||
// if (_baseName == "") then {
|
||||
// _baseName = format[
|
||||
// "near %1",
|
||||
// text (nearestLocation [_base, ["NameCity", "NameLocal"]])
|
||||
// ]
|
||||
// };
|
||||
|
||||
if (_baseName == "") then {
|
||||
_baseName = _base call BIS_fnc_locationDescription;
|
||||
};
|
||||
|
||||
_baseName;
|
||||
10
framework/util/fn_getNearestBase.sqf
Normal file
10
framework/util/fn_getNearestBase.sqf
Normal file
@@ -0,0 +1,10 @@
|
||||
params [["_object", objNull, [objNull]]];
|
||||
if (isNull _object) exitWith {objNull};
|
||||
|
||||
private _bases = missionNamespace getVariable ["milsim_baseObjects", []];
|
||||
if (count _bases == 0) exitWith {objNull};
|
||||
|
||||
// get nearest base (Module_Respawn_F)
|
||||
private _closestBase = [_bases, _object] call BIS_fnc_nearestPosition;
|
||||
if (isNull _closestBase) exitWith {objNull};
|
||||
_closestBase;
|
||||
28
framework/util/fn_log.sqf
Normal file
28
framework/util/fn_log.sqf
Normal file
@@ -0,0 +1,28 @@
|
||||
/*
|
||||
Function: milsim_util_fnc_log
|
||||
|
||||
Description:
|
||||
Used to log messages to the server RPT file.
|
||||
|
||||
Parameters:
|
||||
0: STRING - component name.
|
||||
1: STRING - message to log.
|
||||
2: ARRAY - Key value pairs of data to log.
|
||||
*/
|
||||
|
||||
params [
|
||||
["_component", "", [""]],
|
||||
["_message", "", [""]],
|
||||
["_data", [], [[]]]
|
||||
];
|
||||
|
||||
private _hash = createHashMapFromArray _data;
|
||||
|
||||
// Replace square brackets with round brackets to avoid parsing issues.
|
||||
_message regexReplace ["\[", "("];
|
||||
_message regexReplace ["\]", ")"];
|
||||
|
||||
private _json = [_hash] call CBA_fnc_encodeJSON;
|
||||
_log = format ["[milsim] [%1] [%2] [%3] :: %4", _component, _fnc_scriptNameParent, _message, _json];
|
||||
|
||||
diag_log text _log;
|
||||
23
framework/util/fn_logMissionInfo.sqf
Normal file
23
framework/util/fn_logMissionInfo.sqf
Normal file
@@ -0,0 +1,23 @@
|
||||
[
|
||||
"init",
|
||||
"MISSION INFO",
|
||||
[
|
||||
["serverName", serverName],
|
||||
["worldName", worldName],
|
||||
["missionSeries", getMissionConfigValue ["missionSeries", ""]],
|
||||
["missionName", missionName],
|
||||
["briefingName", briefingName],
|
||||
["overviewText", getMissionConfigValue ["overviewText", ""]],
|
||||
["onLoadName", getMissionConfigValue ["onLoadName", ""]],
|
||||
["onLoadMission", getMissionConfigValue ["onLoadMission", ""]],
|
||||
["missionAuthor", getMissionConfigValue ["author", ""]],
|
||||
["unitSlots", createHashMapFromArray [
|
||||
["EAST", playableSlotsNumber EAST], // 0 is EAST side
|
||||
["WEST", playableSlotsNumber WEST], // 1 is WEST side
|
||||
["RESISTANCE", playableSlotsNumber RESISTANCE], // 2 is RESISTANCE side
|
||||
["CIVILIAN", playableSlotsNumber CIVILIAN], // 3 is CIVILIAN side
|
||||
["SIDEUNKNOWN", 0], // 4 is SIDEUNKNOWN side
|
||||
["LOGIC", playableSlotsNumber sideLogic] // 5 is LOGIC side
|
||||
]]
|
||||
]
|
||||
] call milsim_util_fnc_log;
|
||||
20
framework/util/fn_padString.sqf
Normal file
20
framework/util/fn_padString.sqf
Normal file
@@ -0,0 +1,20 @@
|
||||
params [
|
||||
["_text", "", [""]],
|
||||
["_padSide", "left", ["left", "right"]],
|
||||
["_padChar", " ", [" "]],
|
||||
["_padLength", 4, [4]]
|
||||
];
|
||||
|
||||
// pad a string with a character to a certain length
|
||||
if (_padSide == "left") then {
|
||||
for "_i" from 1 to _padLength - count _text do {
|
||||
_text = _padChar + _text;
|
||||
};
|
||||
};
|
||||
if (_padSide == "right") then {
|
||||
for "_i" from 1 to _padLength - count _text do {
|
||||
_text = _text + _padChar;
|
||||
};
|
||||
};
|
||||
|
||||
_text
|
||||
25
framework/util/fn_recurseSubclasses.sqf
Normal file
25
framework/util/fn_recurseSubclasses.sqf
Normal file
@@ -0,0 +1,25 @@
|
||||
params [
|
||||
["_cfg", configNull, [configNull]],
|
||||
["_code", {}, [{}]]
|
||||
];
|
||||
|
||||
if (isNull _cfg) exitWith {["Provided config is null!"] call BIS_fnc_error};
|
||||
|
||||
|
||||
private _recurseFnc = {
|
||||
params ["_cfg", "_code", ["_recurseCounter", 0]];
|
||||
[_cfg, _recurseCounter] call _code;
|
||||
// get children and recurse
|
||||
private _childCfgs = _cfg call BIS_fnc_returnChildren;
|
||||
if (count _childCfgs isEqualTo 0) exitWith {false};
|
||||
|
||||
{
|
||||
[_x, _code, _recurseCounter + 1] call _recurseFnc;
|
||||
} forEach _childCfgs;
|
||||
false;
|
||||
};
|
||||
|
||||
private _continue = true;
|
||||
while {_continue} do {
|
||||
_continue = [_cfg, _code] call _recurseFnc;
|
||||
};
|
||||
Reference in New Issue
Block a user