Hello! I have some code here, that a community member helped me with, but I accidentally posted it in the Arma 3 editing section. I believe the Params command doesn't work in Arma 2(?) Can someone show me how the script below should look in Arma 2? Thank you ever so :)
private _fnc_getrandindexes = {
params [ ["_array",[],[[]]], ["_indexcnt",1,[0]] ];
if (_array isEqualTo []) exitWith {
//exit if passed _array is empty or not passed, if _indexcnt is not passed using 1
diag_log format ["_fnc_getrandindexes: Passed array is empty: %1 - exiting...",str _array];
};
//define output
private _return_array = [];
//some other prevents
if (_indexcnt isEqualTo 0) then {_indexcnt = 1};
if (_indexcnt > count _array) then {_indexcnt = count _array};
if (_indexcnt isEqualTo (count _array)) exitWith {
// exit with shuffled array if indexes count == _indexcnt
_return_array = _array call BIS_fnc_arrayShuffle;
_return_array
};
//loop
for "_i" from 1 to _indexcnt do {
private _randindex = selectRandom _array;
_return_array pushBack _randindex;
_array = _array - [_randindex];
};
//return
_return_array
};
_array = [variable_01, variable_02, variable_03, variable_04, variable_05];
private _myrandomindxcnt = floor (random (count _array));
private _mynewarray = [_array, _myrandomindxcnt] call _fnc_getrandindexes;
//or if you want to change existing array
_array = [_array, _myrandomindxcnt] call _fnc_getrandindexes;