Jump to content
Sign in to follow this  
Militant1006

Attempting to replace weapons per unit class

Recommended Posts

Recently I have been trying to write a script which replaces all loadouts for a unit class on the map with another, basically swapping the Takistani Army FN FAL's for AKM's, however it is quite tricky.

I have a file called weaponreplace.sqf which has this in it's contents

_typeof_soldier = typeof _soldier;

_riflemen = [

"TK_Soldier_EP1",

"TK_Soldier_B_EP1",

"TK_Soldier_LAT_EP1",

"TK_Soldier_Engineer_EP1",

"TK_Soldier_AMG_EP1",

"TK_Soldier_AAT_EP1",

"TK_Soldier_Night_2_EP1",

"TK_Soldier_TWS_EP1",

"TK_Soldier_Night_1_EP1"

];

if (_typeof_soldier in _riflemen) then {

removeAllWeapons _soldier;

_soldier addMagazine ["30Rnd_762x39_AK47", 6];

_soldier addMagazine ["handGrenade_east", 2];

_soldier addMagazine ["ACE_RDG2", 2];

_soldier addWeapon "ACE_AKM";

_soldier selectWeapon (primaryWeapon _soldier);

};

and I have this being executed from the init.sqf

{_x setVehicleInit "_soldier = this"} forEach allUnits;

processInitCommands;

wpnreplace = [] execVM "Scripts\weaponreplace.sqf";

I have tried replacing all the _soldier with _this and executing off a single soldier's init with

wpnreplace = this execVM "Scripts\weaponreplace.sqf";

and it works fine, replaces the weapon and everything, however I can't figure out a way to send this to each unit across the map, as I plan on checking every soldier type on the Takistani Army side, with almost all having their weapons replaced.

Any ideas?

Share this post


Link to post
Share on other sites

No it won't, I know what LEA does, I need a script which I only have to manually set up once, then from there on it is easy, just execute it and it does what it needs to, on any mission.

All I need is a way to execute this for every soldier on the map.

Share this post


Link to post
Share on other sites

_riflemen = [
"TK_Soldier_EP1",
"TK_Soldier_B_EP1",
"TK_Soldier_LAT_EP1",
"TK_Soldier_Engineer_EP1",
"TK_Soldier_AMG_EP1",
"TK_Soldier_AAT_EP1",
"TK_Soldier_Night_2_EP1",
"TK_Soldier_TWS_EP1",
"TK_Soldier_Night_1_EP1"
];

{
	if ((typeOf _x) in _riflemen) then {
		removeAllWeapons _x;
		_x addMagazine ["30Rnd_762x39_AK47", 6];
		_x addMagazine ["handGrenade_east", 2];
		_x addMagazine ["ACE_RDG2", 2];
		_x addWeapon "ACE_AKM";
		_x selectWeapon (primaryWeapon _x);
	};
}forEach allUnits;

forEach and allUnits

Only needs to run once.

Edited by cuel

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  

×