mirror of
https://github.com/EpochModTeam/DayZ-Epoch.git
synced 2025-12-14 04:02:37 +03:00
More even distribution of return
This commit is contained in:
@@ -8,16 +8,16 @@ Parameters: array
|
|||||||
This returns a randomly selected element from the passed array.
|
This returns a randomly selected element from the passed array.
|
||||||
|
|
||||||
Example: [1,2,3] call BIS_fnc_selectRandom
|
Example: [1,2,3] call BIS_fnc_selectRandom
|
||||||
Returns: 1, 2, or 3
|
Returns: 1, 2, || 3
|
||||||
************************************************************/
|
************************************************************/
|
||||||
|
|
||||||
private "_ret";
|
private "_ret";
|
||||||
|
|
||||||
if(count _this > 0) then
|
if(count _this > 0) then
|
||||||
{
|
{
|
||||||
_ret = (count _this) - 1; //number of elements in the array
|
_ret = count _this; //number of elements in the array
|
||||||
//_ret = [0, _ret] call BIS_fnc_randomInt; //choose random index
|
//_ret = [0, _ret] call BIS_fnc_randomInt; //choose random index
|
||||||
_ret = random _ret;
|
_ret = floor(random _ret);
|
||||||
_ret = _this select _ret; //get the element, return it
|
_ret = _this select _ret; //get the element, return it
|
||||||
};
|
};
|
||||||
_ret
|
_ret
|
||||||
|
|||||||
Reference in New Issue
Block a user