Files
DayZ-Epoch/SQF/dayz_code/compile/epoch_generateKey.sqf
oiad 9b96ddd2c3 Consolidate ItemKeyXXX/Colors to arrays.
Tidies up scripts inside epoch and for script creators.
Moved z_at_buyItems to epoch_generateKey.
2017-11-19 11:27:02 +13:00

27 lines
778 B
Plaintext

/*
- Generates key
- Attempts to add to toolbelt
Usage: _result = call epoch_generateKey;
Returns array:
[bool, string]
[(key added successfully or not), ItemKey## class name]
*/
private ["_isKeyOK","_keyColor","_keyNumber","_keySelected"];
// First select key color
_keyColor = DZE_keyColors call BIS_fnc_selectRandom;
// then select number from 1 - 2500
_keyNumber = (floor(random 2500)) + 1;
// Combine to key (eg.ItemKeyYellow2494) classname
_keySelected = format["ItemKey%1%2",_keyColor,_keyNumber];
_isKeyOK = isClass(configFile >> "CfgWeapons" >> _keySelected);
//Remove melee magazines (BIS_fnc_invAdd fix)
false call dz_fn_meleeMagazines;
_isOk = [player,_keySelected] call BIS_fnc_invAdd;
true call dz_fn_meleeMagazines;
[(_isOk && _isKeyOK),_keySelected]