-
Notifications
You must be signed in to change notification settings - Fork 36
Description
Concerned files:
f_assignGear_fiaAK.sqf
f_assignGear_fia_v.sqf
Problem:
FIA vehicle assignGear uses selectRandom to select a random carbine from f_assignGear_fia.sqf, where _carbine is an array of strings. However, in f_assignGear_fiaAK.sqf, there is only one carbine, and thus _carbine is a string. selectRandom expects an array, and thus an error is returned during compilation.
Workaround:
I fixed it by converting _carbine to an array if it was detected as a string. For this, the code is simply:
if (typeName _carbine isEqualType "") then {_carbine = [_carbine]};
which is added to the top of f_assignGear_fia_v.sqf. This is fine for my mission, but as discussed in the F3 Discord channel, it's probably a bit too hacky for a standard framework.
Fixes:
@Sniperhid suggested that the randomization step be shifted to f_assignGear_fia.sqf itself, so that _carbine is always a string and that other code can safely assume so. For example:
_carbine = selectRandom ["arifle_TRG20_F","arifle_TRG20_F","arifle_Mk20C_plain_F"];
Note that selectRadnom is the "Engine solution to BIS_fnc_selectRandom".
This will obviously need to be done for FIA rifles as well, but more for consistency and optimization, as it doesn't break anything.
Another way of doing it, as mentioned by Ferrard, is to make another vehicle assign gear file like f_assignGear_fiaAK_v.sqf in which the calls to BIS_fn_selectRandom are omitted, and _carbine is used assuming it's a string. I had thought of doing this for my own workaround, but thought it would be a few extra KBs for not much benefit.
Snippers' method is probably the cleanest, safest and most future proof.