Blitzen88 17 Posted July 11, 2019 Greetings, I’m trying to create a script which will rearm CSAT units with Ak12s. However, I do not want the script to apply to machinegunners and marksmen. Can someone show me how to either: 1) Ignore/do not run the script for machinegunners/marksmen (would this be done be excluding certain unit classnames??) 2) Apply the script to units which are armed with a specific type/array of weapon Thank you! Share this post Link to post Share on other sites
scottb613 246 Posted July 11, 2019 Hi... Haven't been scripting in a while - but "getUnitLoadout" should give you what each unit is carrying and allow for comparisons and replacements... https://community.bistudio.com/wiki/getUnitLoadout Regards, Scott Share this post Link to post Share on other sites
wogz187 1085 Posted July 11, 2019 (edited) @Blitzen88, Don't listen to me because I have no idea but it will probably be something like, group= _group (east); { getUnitLoadout ["_csat_class", true];//put the unit class name } forEach units _group this; Just wait for somebody to tell us how wrong I am and then you'll have the answer. EDIT: I guess if that worked at all it would just rearm the units. You want to re-equip them with AK-12's. Edited July 11, 2019 by wogz187 I don't really know stuff Share this post Link to post Share on other sites
Blitzen88 17 Posted July 11, 2019 I didnt know about the unitloadout command. I was wondering if it would be possible to do something along the lines of: If unit class is machinegunner or marksman then exit; else removeweapon, etc Share this post Link to post Share on other sites
pierremgi 4762 Posted July 12, 2019 { _x addEventHandler ["Reloaded",{ params ["_unit", "_weapon", "_muzzle", "_newMagazine", "_oldMagazine"]; systemChat str [_unit,_weapon,_muzzle,_newMagazine,_oldMagazine]; if (_weapon find "Katiba" >-1) then { if (magazines _unit findIf {_x == _oldMagazine #0} < 0) then { _unit addMagazines [_oldMagazine #0, 3]; } } }] } forEach (allUnits select {!isplayer _x}); You just need to replace "Katiba" by a working string from your class name (whole or not, case SenSiTiVe) 1 Share this post Link to post Share on other sites
Blitzen88 17 Posted July 12, 2019 11 hours ago, pierremgi said: { _x addEventHandler ["Reloaded",{ params ["_unit", "_weapon", "_muzzle", "_newMagazine", "_oldMagazine"]; systemChat str [_unit,_weapon,_muzzle,_newMagazine,_oldMagazine]; if (_weapon find "Katiba" >-1) then { if (magazines _unit findIf {_x == _oldMagazine #0} < 0) then { _unit addMagazines [_oldMagazine #0, 3]; } } }] } forEach (allUnits select {!isplayer _x}); You just need to replace "Katiba" by a working string from your class name (whole or not, case SenSiTiVe) Im a scripting newbie but wouldn't this resupply the unit instead of changing weaponry? i think something like this is what Im looking for..? //Add LMG for Autorifleman, otherwise give rifle if (_unitType in _MGSoldiers) then { [_unit, (_possibleMGs call Bis_fnc_selectRandom), 6] call BIS_fnc_addWeapon; } else { if (_unitType in _GLSoldiers) then { {_unit addMagazine "1Rnd_HE_Grenade_shell"} forEach [1,2,3,4,5,6]; [_unit, (_possibleGLWeapons call Bis_fnc_selectRandom), 6] call BIS_fnc_addWeapon; } else { if (_unitType in _MarksmanSoldiers) then { [_unit, (_possibleMarksmanWeapons call Bis_fnc_selectRandom), 6] call BIS_fnc_addWeapon; _unit addPrimaryWeaponItem "optic_Hamr"; } else { [_unit, (_possiblePrimaryWeapons call Bis_fnc_selectRandom), 6] call BIS_fnc_addWeapon; }; }; }; [_unit, (_possibleHandguns call Bis_fnc_selectRandom), 4] call BIS_fnc_addWeapon; //Give AT weapon where appropriate if (_unitType in _ATSoldiers) then { [_unit, (_possibleLaunchers call Bis_fnc_selectRandom), 3] call BIS_fnc_addWeapon; }; //Give Medikit to Medics if (_unitType in _MedicSoldiers) then { _unit addItemToBackpack "Medikit"; {_unit addItemToBackpack "FirstAidKit";} forEach [1,2,3,4,5,6,7,8,9,10]; }; //Give Toolkit to Engineers, etc. if (_unitType in _RepairSoldiers) then { _unit addItemToBackpack "ToolKit"; _unit addItemToBackpack "MineDetector"; {_unit addItemToBackpack "FirstAidKit";} forEach [1,2]; }; Share this post Link to post Share on other sites