Jump to content
  • 0

Proper ammo based on randomized weapon using switch ?


MattL

Question

Basically what i'm wondering is if switch can be used to determine what ammo to add for specific weapons, then correctly add that ammo based on the randomization of said weapons, so something like : 

_wep = "classname";
_wep2 = "classname";

_crateweps = [_wep,_wep2] call BIS_fnc_selectRandom;

_box addWeaponCargoGlobal [_crateweps,1];

switch (true) do {
    case "classname": { _box addMagazineCargoGlobal "classname" };
    case "classname": { _box addMagazineCargoGlobal "classname" };
    default {};
};

Does anyone know if this is how I should go about doing this or if there is another method? 

 

EDIT: Got it working, thanks Infistar!

Link to comment
Share on other sites

3 answers to this question

Recommended Posts

  • 0

 

You could shove this in there.

_ammo = [] + getArray (configFile >> "cfgWeapons" >> _crateweps >> "magazines");
_box addMagazineCargoGlobal (_ammo select 0);

That's actually almost exactly what I ended up settling on doing, with thanks to Infistar. Was just about to update this post with the information haha. Thanks man

Link to comment
Share on other sites

  • 0

That's actually almost exactly what I ended up settling on doing, with thanks to Infistar. Was just about to update this post with the information haha. Thanks man

 

Some weapons have more than one magazine that works for them, so you could take the classname of the weapon into a switch and switch it for specific weapons if the default is not to your liking (such as an MK12 SPR would be giving 20rnd magazines). It would be a different select number.

Link to comment
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
  • Advertisement
  • Discord

×
×
  • Create New...