Kempco 10 Posted January 23, 2013 Is there a way of setting the amount of bullets for a magazine that is added to player? There are green bars indicating magazine status in the gear screen, when those mags are added, if they are not full, load as partially full, so I'm assuming it can be done. //by Kempco _isSilenced = _this select 0; _STAN = _this select 1; _SD = _this select 2; private ["_mag_size","_bullets","_full_mags","_partial_mags"]; _unit = player; _current = currentweapon _unit; _all_mags = []; _mags_to_remove = []; _SD_mags = getArray(configFile >> "CfgWeapons" >> _SD >> "magazines"); _STAN_mags = getArray(configFile >> "CfgWeapons" >> _STAN >> "magazines"); {_all_mags = _all_mags + [tolower _x]} foreach _SD_mags; {_all_mags = _all_mags + [tolower _x]} foreach _STAN_mags; for "_i" from 0 to (count (magazines _unit) - 1) do { _mag = tolower((magazines _unit) select _i); if (_mag in _all_mags) then { _array = if (_isSilenced) then {_STAN_mags}else{_SD_mags}; _mags_to_remove = _mags_to_remove + [_mag]; player addmagazine (_array select 0);//<=============== Magazine is added here, does not accomidate for partial mags. _mag_size = getNumber(configFile >> "CfgMagazines" >> _mag >> "count"); if (_mag_size == (player ammo _current)) then {//<========== (player ammo _current) gotta be somethig that does not require the mag be loaded _full_mags = _full_mags + 1; }else{ _partial_mags = _partial_mags + 1; _bullets = _bullets + (player ammo _current); //<========================?????????????? Partial magazine, need to reduce bullets }; }; /* Tally bullets then dived by mag capcity would work, but need a way of reducing the remainders from partial mags otherwise you start losing mags. _mags_new = _full_mags + floor(_bullets/_mag_size); hint format ["Full Mags: %1\nPartial Mags: %2\nBullets: %3\n\nMags to add: %4",_full_mags,_partial_mags,_bullets,_mags_new]; */ _mags_to_remove spawn { sleep 0.5; {player removeMagazine _x} foreach _this; reload player; }; }; Share this post Link to post Share on other sites
das attorney 857 Posted January 23, 2013 http://community.bistudio.com/wiki/addMagazine_array I think that should be the one :) Share this post Link to post Share on other sites
Kempco 10 Posted January 23, 2013 http://community.bistudio.com/wiki/addMagazine_arrayI think that should be the one :) Sweet! Thanks Das! Share this post Link to post Share on other sites
[frl]myke 14 Posted January 23, 2013 Not addon related, please use the correct forum next time. Moving thread. Share this post Link to post Share on other sites