Random Amounts Of Ammunition In Spawned Magazines

4 posts in this topic

I was wondering if anybody would be so kind as to help me figure out how to get random amounts of ammo in spawned magazines... Im not too keen on how every magazine you come across in the world ends up being full and would like to factor in random amounts. I would also like to point out, Im not a coder and just starting to learn now :) 

Any help would be appreciated peoples   

Share this post

Link to post
Share on other sites

I agree, that would be the best to me as well. However, to do that it would take scripting I believe. It would also make a LOT more use of the combine mags function.

Share this post

Link to post
Share on other sites

It's a good idea. I'm not going to tell you exactly how to do it, but you would be using something like this... 

_lootHolder addMagazineAmmoCargo [_itemClassName, 1, random 30];

ExileServer_system_lootManager_spawnLootInBuilding.sqf is the file that handles loot spawning. 
The command addMagazineAmmoCargo is global, so it should be able to be ran from the server. 
The caveat to this command is finding a good balance of the random number. If you are spawning an 150 round box, 30 may be a little low, but that same command could spawn a 16 round pistol mag, where 30 will max the mag out at 16. 

Figuring out some checks and logic will allow that to be expanded further. Just thought I would push y'all in the right path. :) 


For the people who want to see if this actually works... Run this in editor. Yes, there is a car wheel in there on purpose to prove it doesn't error out on objects that have no "ammo". 


ammoArray = ["150Rnd_93x64_Mag","16Rnd_9x21_Mag","Exile_Item_CarWheel","30Rnd_45ACP_Mag_SMG_01"];

_loot = createVehicle ["LootWeaponHolder", position player, [], 0, "CAN_COLLIDE"];

    _loot addMagazineAmmoCargo [_x, 1, random 30];
} forEach ammoArray;



Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.