Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AssignGear: Improper argument can be fed to BIS_fn_selectRandom #780

Open
osarup opened this issue Jul 27, 2016 · 1 comment
Open

AssignGear: Improper argument can be fed to BIS_fn_selectRandom #780

osarup opened this issue Jul 27, 2016 · 1 comment
Labels

Comments

@osarup
Copy link
Contributor

osarup commented Jul 27, 2016

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.

@osarup osarup added the Bug label Jul 27, 2016
@headswe
Copy link
Collaborator

headswe commented Jul 27, 2016

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants