sbondo1234 6 Posted February 10, 2019 I am trying to add magazines for a weapon to the player when they load a preset kit. I currently have it like this: _unit addItemToBackpack "20Rnd_762x51_Mag"; It works right now and adds one magazine to the player's backpack, but I want to add multiple mags to their backpack with one line of code instead of writing it out 20 times. Any help would be greatly appreciated. Share this post Link to post Share on other sites
MrEmcee 1 Posted February 10, 2019 for "_i" from 0 to 19 do { _unit addItemToBackpack "20Rnd_762x51_Mag" }; This will perform the code in the brackets {} 20 times and give _unit 20 magazines in the backpack. "from 0 to 19" means that the game counts 0, 1, 2, 3... until 19 and including 19. Since it's starting on 0, which adds another digit, the code will run 20 times. if you want, and it would be easier to read, you can also write: for "_i" from 1 to 20 do {}; More info here: https://community.bistudio.com/wiki/for 1 Share this post Link to post Share on other sites
Larrow 2794 Posted February 10, 2019 //Specifically to backpack backpackContainer _unit addMagazineCargoGlobal [ "20Rnd_762x51_Mag", 20 ]; //Any where in units inventory _unit addMagazines [ "20Rnd_762x51_Mag", 20 ]; 3 Share this post Link to post Share on other sites
sbondo1234 6 Posted February 11, 2019 19 hours ago, Larrow said: //Specifically to backpack backpackContainer _unit addMagazineCargoGlobal [ "20Rnd_762x51_Mag", 20 ]; //Any where in units inventory _unit addMagazines [ "20Rnd_762x51_Mag", 20 ]; 19 hours ago, MrEmcee said: for "_i" from 0 to 19 do { _unit addItemToBackpack "20Rnd_762x51_Mag" }; This will perform the code in the brackets {} 20 times and give _unit 20 magazines in the backpack. "from 0 to 19" means that the game counts 0, 1, 2, 3... until 19 and including 19. Since it's starting on 0, which adds another digit, the code will run 20 times. if you want, and it would be easier to read, you can also write: for "_i" from 1 to 20 do {}; More info here: https://community.bistudio.com/wiki/for Thanks a lot! Share this post Link to post Share on other sites