You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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:
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.
The text was updated successfully, but these errors were encountered:
Fint use the function, use the command version. "selectRandom"
-----Original Message-----
From: "Ojas S" [email protected]
Sent: 2016-07-27 11:45
To: "ferstaberinde/F3" [email protected]
Subject: [ferstaberinde/F3] AssignGear: Improper argument can be fed toBIS_fn_selectRandom (#780)
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.
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub, or mute the thread.
Concerned files:
Problem:
FIA vehicle assignGear uses
selectRandom
to select a random carbine fromf_assignGear_fia.sqf
, where_carbine
is an array of strings. However, inf_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: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: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 toBIS_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.
The text was updated successfully, but these errors were encountered: