Jump to content
Sign in to follow this  
Jacksaunt

Problems with removeallweapons this; and forEach possibly?

Recommended Posts

So I'm trying to create an inventory where the player has a weapon, four magazines and an optic. I'm using removeallweapons instead of removing the weapon's classname because it's a quick script and I want it to be usable on any unit.

removeallweapons this; {_X addmagazine "R3F_7Rnd_127x99_PGM"} forEach [1, 2, 3, 4]; this addweapon "R3F_PGM_Hecate_II_POLY"; this addPrimaryWeaponItem "R3F_NF";

When I used this, no weapon would show up. So I used a default weapon instead.

removeallweapons this; {_X addmagazine "20Rnd_762x45"} forEach [1, 2, 3, 4]; this addweapon "arifle_MXM_F"; this addPrimaryWeaponItem "optic_Holosight";

Still nothing shows up.

What would be the issue here? I've searched around a bit and I haven't found anything.

Share this post


Link to post
Share on other sites

this addmagazines ["20Rnd_762x45",4]; this addweapon "arifle_MXM_F"; 

There's no need to use forEach anymore when adding magazines - you can now use unit addmagazines ["magname",number];

Even if you did use the forEach method, it was incorrect because you were using _x, which refers to elements in the array at the end, which was 1-4. To make that work you would have just used

{this addmagazine "20Rnd_762x45"} forEach [1, 2, 3, 4];

Essentially what you were doing was trying to add the magazine to 1, 2, 3 and 4.

Also that mag class isn't correct.

Share this post


Link to post
Share on other sites

Ah, I wasn't sure about the {_X and I knew that the {player wouldn't work well. Thanks for the help, everything works well.

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×