Jump to content
Sign in to follow this  
Ice_Rhino

Different Loadouts for soldiers

Recommended Posts

I am using the following code in the init..sqf

call compileFinal preprocessFileLineNumbers "FAR_revive\FAR_revive_init.sqf";
[] execVM "outlw_magRepack\MagRepack_init.sqf";


waitUntil {!isNull player};
_script = player execVM "sr-loadout.sqf";
waitUntil {scriptDone _script};


With this code in mind, is there anyway that I can set the player's loadout by name. I have a 2 Player mission and I want one to have a custom Sniper = (Player_1) Loadout = (sr-loadout.sqf) and the other to have Spotter = (Player_2) Loadout = (ar-loadout.sqf). I have the two files sqf files containing the kit required but I am not sure how to implement it via the init.sqf file

Any assistance would be appreciated

Thanks

Share this post


Link to post
Share on other sites

Within the script you would just have a classname checks, or vehicle variable name:

_unit = (_this select 0);

if (typeOf _unit == "B_Sniper_F") then {...loadout code...} else if (typeOf _unit == "B_Spotter_F") then {...loadout code....};

//Or if using variable names

if (vehicleVarName _unit == Player1) then {...loadout code...} else if (vehicleVarName _unit == Player2) then {...loadout code....};

This also allows you to cut down on the extra sqfs :p.

Edited by JShock

Share this post


Link to post
Share on other sites

Hi JS,

I am going to have to start paying you soon with all these stupid questions I keep asking

Where do I put said code, 'unit initial...' or still in the init.sqf file?

Share this post


Link to post
Share on other sites
Hi JS,

I am going to have to start paying you soon with all these stupid questions I keep asking

Where do I put said code, 'unit initial...' or still in the init.sqf file?

This would go into a sqf, idk let's call it loadout.sqf, so the call line would go into your unit's init field (nul = [this] execVM "loadout.sqf"; ), and then where you see the "...loadout code..." above you can take whatever code you have for those unit's specific loadouts and place it there, instead of having two other sqf calls (your sr-loadout and ar-loadout).

In doing this you will have the one loadout script, just more efficient :p.

Share this post


Link to post
Share on other sites

I tried to make the init.sqf as follows but when the mission loaded I had stock sniper loadout

call compileFinal preprocessFileLineNumbers "FAR_revive\FAR_revive_init.sqf";
[] execVM "outlw_magRepack\MagRepack_init.sqf";


if (typeOf _unit == "B_Sniper_F") then {sr-loadout.sqf} else if (typeOf _unit == "B_Spotter_F") then {ar-loadout.sqf};

Not sure where to head from here. I tried putting your code into the INITIAL of the unit and added the loadout.sqf in place and it errored with no information and would not accept the entry

Hope you can help me JS :)

---------- Post added at 19:58 ---------- Previous post was at 19:56 ----------

Understood, I shall try that now. Thanks JS

Share this post


Link to post
Share on other sites

There are no calls in the init.sqf.

And what I'm saying for the loadout.sqf (fully exampled, put your loadout scripts in place of):

_unit = (_this select 0);

if (typeOf _unit == "B_Sniper_F") then {

_unit addUniform "Blah_Classname_Uniform";
_unit addWeapon "Minigun";
_unit add etc. etc. etc.

} else if (typeOf _unit == "B_Spotter_F") then {

_unit addUniform "Blah_Classname_Uniform";
_unit addWeapon "Non_Minigun";
_unit add etc. etc. etc.

};

Then in each of the unit's init fields put:

nul = [this] execVM "loadout.sqf";

Share this post


Link to post
Share on other sites

Hi

I placed in unit's initialization

bluplagro = group this; this moveInCargo [blu_inshel_1, 3];(nul = [this] execVM "loadout.sqf");

But it won't accept the entry. It says it is mission a ] or ), can't quite make out which

also the content of the newly created loadout.sqf

if (typeOf _unit == "B_Sniper_F") then {sr-loadout.sqf} else if (typeOf _unit == "B_Spotter_F") then {ar-loadout.sqf};

Thanks JS

---------- Post added at 20:12 ---------- Previous post was at 20:06 ----------

OK, I think we are crossing threads here, you are being helpful and I am being a coding idiot. Let me digest your last expanded script entry and try to work it out

Sorry about this JS, about being thick I mean

---------- Post added at 20:13 ---------- Previous post was at 20:12 ----------

There are no calls in the init.sqf.

And what I'm saying for the loadout.sqf (fully exampled, put your loadout scripts in place of):

_unit = (_this select 0);

if (typeOf _unit == "B_Sniper_F") then {

_unit addUniform "Blah_Classname_Uniform";
_unit addWeapon "Minigun";
_unit add etc. etc. etc.

} else if (typeOf _unit == "B_Spotter_F") then {

_unit addUniform "Blah_Classname_Uniform";
_unit addWeapon "Non_Minigun";
_unit add etc. etc. etc.

};

Then in each of the unit's init fields put:

nul = [this] execVM "loadout.sqf";

I think I understand now. Let me try it now

---------- Post added at 20:21 ---------- Previous post was at 20:13 ----------

Is it OK to put the contents of my sr-loadout.sqf as is below;

_unit = _this;


_arrayOfItems = ["ItemCompass", "itemGPS", "itemMap", "itemRadio", "itemWatch"];
_arrayOfWeaponItems = ["acc_pointer_IR", "optic_LRPS", "srifle_LRR_SOS_F"];


removeAllWeapons _unit;
removeAllAssignedItems _unit;
removeAllContainers _unit;
removeUniform _unit;    
removeVest _unit;   
removeBackpack _unit;  


_unit addUniform "U_B_GhillieSuit";
_unit addVest "V_PlateCarrierH_CTRG";   
_unit addBackpack "B_TacticalPack_mcamo";   
_unit addGoggles "G_Shades_Black";  


_unit addWeapon "srifle_LRR_SOS_F" ;
_unit addWeapon "hgun_P07_F";
_unit addWeapon "Rangefinder";


_unit addMagazines ["7Rnd_408_Mag", 20];
_unit addMagazines ["16Rnd_9x21_Mag", 3];
{
   _unit addItem _x;
   _unit assignItem _x;
} forEach _arrayOfItems;


{
   _unit addPrimaryWeaponItem _x;
} forEach _arrayOfWeaponItems;


_unit addItem "optic_Nightstalker";
_unit addItem "FirstAidKit";   
_unit addItem "FirstAidKit";  
_unit addItem "FirstAidKit";
_unit addItem "FirstAidKit";  
_unit addItem "FirstAidKit";
_unit addItem "FirstAidKit";  
_unit addItem "FirstAidKit";
_unit addItem "NVGoggles";

Thanks JS

---------- Post added at 20:47 ---------- Previous post was at 20:21 ----------

Hi JS,

OK, story so far. If I use the first part of your code as below, then it works fine for either classname. However if I put the 'else' if in and the second config, neither get assigned;

_unit = (_this select 0);


if (typeOf _unit == "B_Sniper_F") then {
_arrayOfItems = ["NVGoggles", "ItemCompass", "itemGPS", "itemMap", "itemRadio", "itemWatch"];
_arrayOfWeaponItems = ["acc_pointer_IR", "optic_Nightstalker", "muzzle_snds_B", "srifle_EBR_F"];


removeAllWeapons _unit;
removeAllAssignedItems _unit;
removeAllContainers _unit;
removeUniform _unit;    
removeVest _unit;   
removeBackpack _unit;  


_unit addUniform "U_B_CombatUniform_mcam";
_unit addVest "V_PlateCarrierH_CTRG";   
_unit addBackpack "B_TacticalPack_mcamo";   
_unit addHeadgear "H_Booniehat_mcamo";   
_unit addGoggles "G_Shades_Black";  


_unit addWeapon "srifle_EBR_F" ;
_unit addWeapon "hgun_P07_F";
_unit addWeapon "Binocular";


_unit addMagazines ["20Rnd_762x51_Mag", 20];
_unit addMagazines ["16Rnd_9x21_Mag", 3];
_unit addMagazines ["DemoCharge_Remote_Mag", 4];
{
   _unit addItem _x;
   _unit assignItem _x;
} forEach _arrayOfItems;


{
   _unit addPrimaryWeaponItem _x;
} forEach _arrayOfWeaponItems;


_unit addItem "FirstAidKit";   
_unit addItem "optic_DMS";
_unit addItem "FirstAidKit";  
_unit addItem "FirstAidKit";
_unit addItem "FirstAidKit";  
_unit addItem "FirstAidKit";
_unit addItem "FirstAidKit";  
_unit addItem "FirstAidKit";
}

Any thoughts?

Edited by Ice_Rhino
added code

Share this post


Link to post
Share on other sites

Sorry think I missed a couple brackets:

_unit = (_this select 0);

if (typeOf _unit == "B_Sniper_F") then {

_unit addUniform "Blah_Classname_Uniform";
_unit addWeapon "Minigun";
_unit add etc. etc. etc.

} else {<<<<***This One     if (typeOf _unit == "B_Spotter_F") then {

_unit addUniform "Blah_Classname_Uniform";
_unit addWeapon "Non_Minigun";
_unit add etc. etc. etc.
};//<<<<<And this one

};  

Share this post


Link to post
Share on other sites

HI JS,

What follows is the content of the loadout.sqf. Neither soldier gets any of this equipment;

_unit = (_this select 0); 


if (typeOf _unit == "B_Sniper_F") then { 


_arrayOfItems = ["ItemCompass", "itemGPS", "itemMap", "itemRadio", "itemWatch"];
_arrayOfWeaponItems = ["acc_pointer_IR", "optic_LRPS", "srifle_LRR_SOS_F"];


removeAllWeapons _unit;
removeAllAssignedItems _unit;
removeAllContainers _unit;
removeUniform _unit;    
removeVest _unit;   
removeBackpack _unit;  


_unit addUniform "U_B_GhillieSuit";
_unit addVest "V_PlateCarrierH_CTRG";   
_unit addBackpack "B_TacticalPack_mcamo";   
_unit addGoggles "G_Shades_Black";  


_unit addWeapon "srifle_LRR_SOS_F" ;
_unit addWeapon "hgun_P07_F";
_unit addWeapon "Rangefinder";


_unit addMagazines ["7Rnd_408_Mag", 20];
_unit addMagazines ["16Rnd_9x21_Mag", 3];
{
   _unit addItem _x;
   _unit assignItem _x;
} forEach _arrayOfItems;


{
   _unit addPrimaryWeaponItem _x;
} forEach _arrayOfWeaponItems;


_unit addItem "optic_Nightstalker";
_unit addItem "FirstAidKit";   
_unit addItem "FirstAidKit";  
_unit addItem "FirstAidKit";
_unit addItem "FirstAidKit";  
_unit addItem "FirstAidKit";
_unit addItem "FirstAidKit";  
_unit addItem "FirstAidKit";
_unit addItem "NVGoggles";


} else {<<<<***This One     if (typeOf _unit == "B_Spotter_F") then { 
_arrayOfItems = ["NVGoggles", "ItemCompass", "itemGPS", "itemMap", "itemRadio", "itemWatch"];
_arrayOfWeaponItems = ["acc_pointer_IR", "optic_Nightstalker", "muzzle_snds_B", "srifle_EBR_F"];


removeAllWeapons _unit;
removeAllAssignedItems _unit;
removeAllContainers _unit;
removeUniform _unit;    
removeVest _unit;   
removeBackpack _unit;  


_unit addUniform "U_B_CombatUniform_mcam";
_unit addVest "V_PlateCarrierH_CTRG";   
_unit addBackpack "B_TacticalPack_mcamo";   
_unit addHeadgear "H_Booniehat_mcamo";   
_unit addGoggles "G_Shades_Black";  


_unit addWeapon "srifle_EBR_F" ;
_unit addWeapon "hgun_P07_F";
_unit addWeapon "Binocular";


_unit addMagazines ["20Rnd_762x51_Mag", 20];
_unit addMagazines ["16Rnd_9x21_Mag", 3];
_unit addMagazines ["DemoCharge_Remote_Mag", 4];
{
   _unit addItem _x;
   _unit assignItem _x;
} forEach _arrayOfItems;


{
   _unit addPrimaryWeaponItem _x;
} forEach _arrayOfWeaponItems;


_unit addItem "FirstAidKit";   
_unit addItem "optic_DMS";
_unit addItem "FirstAidKit";  
_unit addItem "FirstAidKit";
_unit addItem "FirstAidKit";  
_unit addItem "FirstAidKit";
_unit addItem "FirstAidKit";  
_unit addItem "FirstAidKit";
}; 


};  

Thanks for the help JS

T

Share this post


Link to post
Share on other sites
I am using the following code in the init..sqf

call compileFinal preprocessFileLineNumbers "FAR_revive\FAR_revive_init.sqf";
[] execVM "outlw_magRepack\MagRepack_init.sqf";


waitUntil {!isNull player};
_script = player execVM "sr-loadout.sqf";
waitUntil {scriptDone _script};


With this code in mind, is there anyway that I can set the player's loadout by name. I have a 2 Player mission and I want one to have a custom Sniper = (Player_1) Loadout = (sr-loadout.sqf) and the other to have Spotter = (Player_2) Loadout = (ar-loadout.sqf). I have the two files sqf files containing the kit required but I am not sure how to implement it via the init.sqf file

Any assistance would be appreciated

Thanks

If I understood you correctly you want to set unit loadout which depends on the slot they joined in MP and you want this to be distinguishable by unit editor name? Then name your units for example sniper and spotter (add the same into description field so you can see which slot belongs to whom on MP role selection, but not necessary). Your modified script then will look like this:

[color="#FF8040"][color="#191970"][b]call[/b][/color] [color="#191970"][b]compileFinal[/b][/color] [color="#191970"][b]preprocessFileLineNumbers[/b][/color] [color="#7A7A7A"]"FAR_revive\FAR_revive_init.sqf"[/color][color="#8B3E2F"][b];[/b][/color]
[color="#8B3E2F"][b][[/b][/color][color="#8B3E2F"][b]][/b][/color] [color="#191970"][b]execVM[/b][/color] [color="#7A7A7A"]"outlw_magRepack\MagRepack_init.sqf"[/color][color="#8B3E2F"][b];[/b][/color]
[color="#191970"][b]waitUntil[/b][/color] [color="#8B3E2F"][b]{[/b][/color][color="#8B3E2F"][b]![/b][/color][color="#191970"][b]isNull[/b][/color] [color="#000000"]player[/color][color="#8B3E2F"][b]}[/b][/color][color="#8B3E2F"][b];[/b][/color]


[color="#191970"][b]switch[/b][/color] [color="#8B3E2F"][b]([/b][/color][color="#191970"][b]toLower[/b][/color] [color="#191970"][b]vehicleVarName[/b][/color] [color="#000000"]player[/color][color="#8B3E2F"][b])[/b][/color] [color="#191970"][b]do[/b][/color] [color="#8B3E2F"][b]{[/b][/color]
[color="#191970"][b]case[/b][/color] [color="#7A7A7A"]"sniper"[/color][color="#8B3E2F"][b]:[/b][/color] [color="#8B3E2F"][b]{[/b][/color]
	[color="#1874CD"]_script[/color] [color="#8B3E2F"][b]=[/b][/color] [color="#000000"]player[/color] [color="#191970"][b]execVM[/b][/color] [color="#7A7A7A"]"sr-loadout.sqf"[/color][color="#8B3E2F"][b];[/b][/color]
	[color="#191970"][b]waitUntil[/b][/color] [color="#8B3E2F"][b]{[/b][/color][color="#191970"][b]scriptDone[/b][/color] [color="#1874CD"]_script[/color][color="#8B3E2F"][b]}[/b][/color][color="#8B3E2F"][b];[/b][/color]
[color="#8B3E2F"][b]}[/b][/color][color="#8B3E2F"][b];[/b][/color]
[color="#191970"][b]case[/b][/color] [color="#7A7A7A"]"spotter"[/color][color="#8B3E2F"][b]:[/b][/color] [color="#8B3E2F"][b]{[/b][/color]
	[color="#1874CD"]_script[/color] [color="#8B3E2F"][b]=[/b][/color] [color="#000000"]player[/color] [color="#191970"][b]execVM[/b][/color] [color="#7A7A7A"]"ar-loadout.sqf"[/color][color="#8B3E2F"][b];[/b][/color]
	[color="#191970"][b]waitUntil[/b][/color] [color="#8B3E2F"][b]{[/b][/color][color="#191970"][b]scriptDone[/b][/color] [color="#1874CD"]_script[/color][color="#8B3E2F"][b]}[/b][/color][color="#8B3E2F"][b];[/b][/color]
[color="#8B3E2F"][b]}[/b][/color][color="#8B3E2F"][b];[/b][/color]
[color="#8B3E2F"][b]}[/b][/color][color="#8B3E2F"][b];[/b][/color][/color]

Edited by Killzone_Kid

Share this post


Link to post
Share on other sites

JS,

So now the code looks like the following and still I have stock Sniper equipment. I trust in you completely but I am obvious doing something stupid here. I hope your patience lasts :)

_unit = (_this select 0); 


if (typeOf _unit == "B_Sniper_F") then { 


_arrayOfItems = ["ItemCompass", "itemGPS", "itemMap", "itemRadio", "itemWatch"];
_arrayOfWeaponItems = ["acc_pointer_IR", "optic_LRPS", "srifle_LRR_SOS_F"];


removeAllWeapons _unit;
removeAllAssignedItems _unit;
removeAllContainers _unit;
removeUniform _unit;    
removeVest _unit;   
removeBackpack _unit;  


_unit addUniform "U_B_GhillieSuit";
_unit addVest "V_PlateCarrierH_CTRG";   
_unit addBackpack "B_TacticalPack_mcamo";   
_unit addGoggles "G_Shades_Black";  


_unit addWeapon "srifle_LRR_SOS_F" ;
_unit addWeapon "hgun_P07_F";
_unit addWeapon "Rangefinder";


_unit addMagazines ["7Rnd_408_Mag", 20];
_unit addMagazines ["16Rnd_9x21_Mag", 3];
{
   _unit addItem _x;
   _unit assignItem _x;
} forEach _arrayOfItems;


{
   _unit addPrimaryWeaponItem _x;
} forEach _arrayOfWeaponItems;


_unit addItem "optic_Nightstalker";
_unit addItem "FirstAidKit";   
_unit addItem "FirstAidKit";  
_unit addItem "FirstAidKit";
_unit addItem "FirstAidKit";  
_unit addItem "FirstAidKit";
_unit addItem "FirstAidKit";  
_unit addItem "FirstAidKit";
_unit addItem "NVGoggles";
}
else if (typeOf _unit == "B_Spotter_F") then { 
_arrayOfItems = ["NVGoggles", "ItemCompass", "itemGPS", "itemMap", "itemRadio", "itemWatch"];
_arrayOfWeaponItems = ["acc_pointer_IR", "optic_Nightstalker", "muzzle_snds_B", "srifle_EBR_F"];


removeAllWeapons _unit;
removeAllAssignedItems _unit;
removeAllContainers _unit;
removeUniform _unit;    
removeVest _unit;   
removeBackpack _unit;  


_unit addUniform "U_B_CombatUniform_mcam";
_unit addVest "V_PlateCarrierH_CTRG";   
_unit addBackpack "B_TacticalPack_mcamo";   
_unit addHeadgear "H_Booniehat_mcamo";   
_unit addGoggles "G_Shades_Black";  


_unit addWeapon "srifle_EBR_F" ;
_unit addWeapon "hgun_P07_F";
_unit addWeapon "Binocular";


_unit addMagazines ["20Rnd_762x51_Mag", 20];
_unit addMagazines ["16Rnd_9x21_Mag", 3];
_unit addMagazines ["DemoCharge_Remote_Mag", 4];
{
   _unit addItem _x;
   _unit assignItem _x;
} forEach _arrayOfItems;


{
   _unit addPrimaryWeaponItem _x;
} forEach _arrayOfWeaponItems;


_unit addItem "FirstAidKit";   
_unit addItem "optic_DMS";
_unit addItem "FirstAidKit";  
_unit addItem "FirstAidKit";
_unit addItem "FirstAidKit";  
_unit addItem "FirstAidKit";
_unit addItem "FirstAidKit";  
_unit addItem "FirstAidKit";
};  

Thanks JS

---------- Post added at 21:52 ---------- Previous post was at 21:30 ----------

Hi Killzone,

I have tried your code and it seems to sort of work. When I made the player(me) the sniper, I got the right kit but the AI did not. When I made the player(me) the spotter, I got the right kit but the AI did not.

Weird, can you not define what AI units have?

T

Share this post


Link to post
Share on other sites
Hi Killzone,

I have tried your code and it seems to sort of work. When I made the player(me) the sniper, I got the right kit but the AI did not. When I made the player(me) the spotter, I got the right kit but the AI did not.

Weird, can you not define what AI units have?

T

Well, you said 2 players, AI technically is not a player. Also AI doesn't have own init.sqf to run because it is not a client either. My script was for 2 human players in Multiplayer. If this is for you and AI then you probably need to move your loadout into "init" of each unit (INITIALIZATION in editor)

[color="#FF8040"][color="#006400"][i]//sniper INITIALIZATION[/i][/color]
[color="#191970"][b]if[/b][/color] [color="#8B3E2F"][b]([/b][/color][color="#191970"][b]local[/b][/color] this[color="#8B3E2F"][b])[/b][/color] [color="#191970"][b]then[/b][/color] [color="#8B3E2F"][b]{[/b][/color]this [color="#191970"][b]execVM[/b][/color] [color="#7A7A7A"]"sr-loadout.sqf"[/color][color="#8B3E2F"][b]}[/b][/color][color="#8B3E2F"][b];[/b][/color]
[color="#006400"][i]//spotter INITIALIZATION[/i][/color]
[color="#191970"][b]if[/b][/color] [color="#8B3E2F"][b]([/b][/color][color="#191970"][b]local[/b][/color] this[color="#8B3E2F"][b])[/b][/color] [color="#191970"][b]then[/b][/color] [color="#8B3E2F"][b]{[/b][/color]this [color="#191970"][b]execVM[/b][/color] [color="#7A7A7A"]"ar-loadout.sqf"[/color][color="#8B3E2F"][b]}[/b][/color][color="#8B3E2F"][b];[/b][/color]

[color="#006400"][i]//init.sqf[/i][/color]
[color="#191970"][b]call[/b][/color] [color="#191970"][b]compileFinal[/b][/color] [color="#191970"][b]preprocessFileLineNumbers[/b][/color] [color="#7A7A7A"]"FAR_revive\FAR_revive_init.sqf"[/color][color="#8B3E2F"][b];[/b][/color]
[color="#8B3E2F"][b][[/b][/color][color="#8B3E2F"][b]][/b][/color] [color="#191970"][b]execVM[/b][/color] [color="#7A7A7A"]"outlw_magRepack\MagRepack_init.sqf"[/color][color="#8B3E2F"][b];[/b][/color]
[color="#191970"][b]waitUntil[/b][/color] [color="#8B3E2F"][b]{[/b][/color][color="#8B3E2F"][b]![/b][/color][color="#191970"][b]isNull[/b][/color] [color="#000000"]player[/color][color="#8B3E2F"][b]}[/b][/color][color="#8B3E2F"][b];[/b][/color][/color]

Share this post


Link to post
Share on other sites
Hi Killzone,

I have tried your code and it seems to sort of work. When I made the player(me) the sniper, I got the right kit but the AI did not. When I made the player(me) the spotter, I got the right kit but the AI did not.

Weird, can you not define what AI units have?

The way Killzone has it structured based on a switch, but he has it where it is "player" only, so it won't do AI.

Here, tested and working (you had accidently deleted one of the curly braces and forgot the one down at the bottom :p ):

_unit = (_this select 0); 


if (typeOf _unit == "B_Sniper_F") then { 


_arrayOfItems = ["ItemCompass", "itemGPS", "itemMap", "itemRadio", "itemWatch"];
_arrayOfWeaponItems = ["acc_pointer_IR", "optic_LRPS", "srifle_LRR_SOS_F"];


removeAllWeapons _unit;
removeAllAssignedItems _unit;
removeAllContainers _unit;
removeUniform _unit;    
removeVest _unit;   
removeBackpack _unit;  


_unit addUniform "U_B_GhillieSuit";
_unit addVest "V_PlateCarrierH_CTRG";   
_unit addBackpack "B_TacticalPack_mcamo";   
_unit addGoggles "G_Shades_Black";  


_unit addWeapon "srifle_LRR_SOS_F" ;
_unit addWeapon "hgun_P07_F";
_unit addWeapon "Rangefinder";


_unit addMagazines ["7Rnd_408_Mag", 20];
_unit addMagazines ["16Rnd_9x21_Mag", 3];
{
    _unit addItem _x;
    _unit assignItem _x;
} forEach _arrayOfItems;


{
   	_unit addPrimaryWeaponItem _x;
} forEach _arrayOfWeaponItems;


_unit addItem "optic_Nightstalker";
_unit addItem "FirstAidKit";
_unit addItem "FirstAidKit";  
_unit addItem "FirstAidKit";
_unit addItem "FirstAidKit";  
_unit addItem "FirstAidKit";
_unit addItem "FirstAidKit";  
_unit addItem "FirstAidKit";
_unit addItem "NVGoggles";
}
else 
{ 

if (typeOf _unit == "B_Spotter_F") then { 
_arrayOfItems = ["NVGoggles", "ItemCompass", "itemGPS", "itemMap", "itemRadio", "itemWatch"];
_arrayOfWeaponItems = ["acc_pointer_IR", "optic_Nightstalker", "muzzle_snds_B", "srifle_EBR_F"];


removeAllWeapons _unit;
removeAllAssignedItems _unit;
removeAllContainers _unit;
removeUniform _unit;    
removeVest _unit;   
removeBackpack _unit;  


_unit addUniform "U_B_CombatUniform_mcam";
_unit addVest "V_PlateCarrierH_CTRG";   
_unit addBackpack "B_TacticalPack_mcamo";   
_unit addHeadgear "H_Booniehat_mcamo";   
_unit addGoggles "G_Shades_Black";  


_unit addWeapon "srifle_EBR_F" ;
_unit addWeapon "hgun_P07_F";
_unit addWeapon "Binocular";


_unit addMagazines ["20Rnd_762x51_Mag", 20];
_unit addMagazines ["16Rnd_9x21_Mag", 3];
_unit addMagazines ["DemoCharge_Remote_Mag", 4];
{
_unit addItem _x;
_unit assignItem _x;
} forEach _arrayOfItems;


{
	_unit addPrimaryWeaponItem _x;
} forEach _arrayOfWeaponItems;


_unit addItem "FirstAidKit";   
_unit addItem "optic_DMS";
_unit addItem "FirstAidKit";  
_unit addItem "FirstAidKit";
_unit addItem "FirstAidKit";  
_unit addItem "FirstAidKit";
_unit addItem "FirstAidKit";  
_unit addItem "FirstAidKit";
  };

};

Share this post


Link to post
Share on other sites

Thanks JS & KZK,

I have luxury of two solutions now. Some more stuff I have learned today thanks to you.

Kindest Regards

Share this post


Link to post
Share on other sites

I'd use switch over ifs. If you are going to use ifs to loadout units, there's no need to use if else if structure. A simple if if if structure is fine and much cleaner especially if there's a lot to be wrote.

//cleaner than if else if
if (typeOf _unit == "B_Sniper_F") then { ... code ... };
if (typeOf _unit == "B_spotter_F") then { ... code ... };
if (typeOf _unit == "B_guy_F") then { ... code ... };

// More efficient (best imo) - - - cAsE SeNsiTiVE
switch {typeOf _unit} do {
    case "B_Sniper_F":{ ... code ... };
    case "B_spotter_F":{ ... code ... };
    case "B_guy_F":{ ... code ... };
};

Edited by Iceman77

Share this post


Link to post
Share on other sites
I'd use switch over ifs. If you are going to use ifs to loadout units, there's no need to use if else if structure. A simple if if if structure is fine and much cleaner especially if there's a lot to be wrote.

Yep I would have recommended the same thing had he not said it was a two player mission, the switch would have been a little overkill in my opinion anyhow :p.

Share this post


Link to post
Share on other sites

Thanks to you both for your help on this. Very much appreciated. Next stupid question coming up on the forum shortly :)

Kindest Regards

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  

×