Jump to content
vurelo

Merging five gear load out scripts into one?

Recommended Posts

Is that a way to merge five gear load out scripts no one, without afect the function of scripts?

Share this post


Link to post
Share on other sites

params ["_loadout"];

switch (toLower _loadout) do

{

case "rifleman": {/*gear script 1*/};

case "sniper": {/*gear script 2 */};

etc...

};

On my phone, so it's hard to be more explicit.

  • Like 1

Share this post


Link to post
Share on other sites
params ["_loadout"];

switch (toLower _loadout) do
{
    case "rifleman": {/*gear script 1*/};
    case "sniper": {/*gear script 2 */};
    etc...
};
On my phone, so it's hard to be more explicit.

 

many thx, now with this example i can understand better !! in the "gear script 1" I can put it that way >> execVM 'myGear.sqf'; ?? 

Share this post


Link to post
Share on other sites

Correct. And to use the above it would look something like:

["RIFLEMAN"] execVM "chooseLoadout.sqf";
  • Like 1

Share this post


Link to post
Share on other sites

Like this??

 

params ["_loadout"];
 
switch (toLower _loadout) do
{
    case "rifleman": ["RIFLEMAN"] execVM "rifleman.sqf";
    case "sniper": ["SNIPER"] execVM "sniper.sqf";
    case "missile Specialist (AT)": ["MISSILE SPECIALIST (AT)"] execVM "AT.sqf";
    case "missile Specialist (AA)": ["MISSILE SPECIALIST (AA)"] execVM "AA.sqf";
    case "heavy Gunner": ["HEAVY GUNNER"] execVM "heavygunner.sqf";
    case "combat Life Saver": ["COMBAT LIFE SAVER"] execVM "medic.sqf";
    case "grenadier": ["GRANADIER"] execVM "grenadier.sqf";
    
};

Share this post


Link to post
Share on other sites

Can you post one of your loadout scripts here, and I assume they all follow the same general format aside from the actual gear in them? (At an actual computer now)

Share this post


Link to post
Share on other sites

Can you post one of your loadout scripts here, and I assume they all follow the same general format aside from the actual gear in them? (At an actual computer now)

private ["_unit"];
_unit = __unit select 0;
IF(!local _unit) exitwith {};
 
//comment "Exported from Arsenal by Ribeiro";
 
//comment "Remove existing items";
removeAllWeapons _unit;
removeAllItems _unit;
removeAllAssignedItems _unit;
removeUniform _unit;
removeVest _unit;
removeBackpack _unit;
removeHeadgear _unit;
removeGoggles _unit;
 
//comment "Add containers";
_unit forceAddUniform "U_B_CombatUniform_mcam_vest";
for "_i" from 1 to 14 do {_unit addItemToUniform "ACE_fieldDressing";};
for "_i" from 1 to 6 do {_unit addItemToUniform "ACE_morphine";};
_unit addItemToUniform "ACE_MapTools";
for "_i" from 1 to 3 do {_unit addItemToUniform "ACE_EarPlugs";};
_unit addVest "V_PlateCarrierL_CTRG";
for "_i" from 1 to 3 do {_unit addItemToVest "rhsusf_mag_7x45acp_MHP";};
for "_i" from 1 to 4 do {_unit addItemToVest "HandGrenade";};
for "_i" from 1 to 3 do {_unit addItemToVest "SmokeShell";};
_unit addBackpack "B_AssaultPack_rgr";
for "_i" from 1 to 2 do {_unit addItemToBackpack "muzzle_snds_H";};
for "_i" from 1 to 2 do {_unit addItemToBackpack "ACE_plasmaIV";};
_unit addItemToBackpack "ACE_bloodIV";
_unit addItemToBackpack "ACE_surgicalKit";
for "_i" from 1 to 5 do {_unit addItemToBackpack "ACE_atropine";};
for "_i" from 1 to 5 do {_unit addItemToBackpack "ACE_epinephrine";};
for "_i" from 1 to 3 do {_unit addItemToBackpack "100Rnd_65x39_caseless_mag";};
_unit addHeadgear "rhsusf_mich_helmet_marpatd";
_unit addGoggles "G_Bandanna_beast";
 
//comment "Add weapons";
_unit addWeapon "arifle_MX_SW_F";
_unit addPrimaryWeaponItem "rhsusf_acc_anpeq15A";
_unit addPrimaryWeaponItem "optic_Hamr";
_unit addPrimaryWeaponItem "bipod_01_F_snd";
_unit addWeapon "rhsusf_weap_m1911a1";
_unit addWeapon "Laserdesignator";
 
//comment "Add items";
_unit linkItem "ItemMap";
_unit linkItem "ItemCompass";
_unit linkItem "ItemWatch";
_unit linkItem "ItemRadio";
_unit linkItem "ItemGPS";
_unit linkItem "ACE_NVG_Gen4";
 
//comment "Set identity";
_unit setFace "WhiteHead_02";
_unit setSpeaker "Male01ENG";

Share this post


Link to post
Share on other sites

With the following you pass in the unit that is being loaded out and the loadout type:

//example exec line (in a unit's init line): [this,"RIFLEMAN"] execVM "chooseLoadout.sqf";

params ["_unit","_loadout"];
 
switch (toLower _loadout) do
{
    case "rifleman": {[_unit] execVM "rifleman.sqf";};
    case "sniper": {[_unit] execVM "sniper.sqf";};
    case "missile specialist (at)": {[_unit] execVM "AT.sqf";};
    case "missile specialist (aa)": {[_unit] execVM "AA.sqf";};
    case "heavy gunner": {[_unit] execVM "heavygunner.sqf";};
    case "combat life saver": {[_unit] execVM "medic.sqf";};
    case "grenadier": {[_unit] execVM "grenadier.sqf";};
};
  • Like 1

Share this post


Link to post
Share on other sites

not sure if this will be helpful or make it more confusing. this is the method we use, it is based on the classname of each unit

 

initPlayerLocal.sqf in mission root (this should do for now, if you only want it to fire once per player per mission then you need more code...)

[player, typeof player] execvm "gear.sqf";

gear.sqf

private ["_unit", "_type"];
_unit = _this select 0;
_type = _this select 1;
 
if (!local _unit) exitWith {};
 
private "_headgear";
_headgear = [ "rhs_6b28",
"rhs_6b28_ess"
];
 
private "_uniform";
_uniform = "rhs_uniform_gorka_r_g";
 
private "_vest";
_vest = [
"rhs_6b23_digi_6sh92",
"rhs_6b23_digi_6sh92_headset",
"rhs_6b23_digi_6sh92_radio",
"rhs_6b23_digi_medic",
"rhs_6b23_digi_vydra_3m"
];
 
private "_backpack";
_backpack = ["rhs_assault_umbts","rhs_sidor"];
 
private "_assigneditems";
_assigneditems = ["ItemMap","ItemCompass","ItemWatch","itemradio","NVGoggles_INDEP"];
 
private "_pistol";
_pistol = "RH_mak";
 
private "_state";
_state = switch tolower(_type) do {
 
// Squadleader
case "fox_opfor_sf_squadleader": {                   // change classnames to suit yourself
[
_headgear call bis_fnc_selectrandom,                 // add random headgear from _headgear array at top of script
_uniform,                                            // add uniform defined at top (u can randomise this too)
_vest call bis_fnc_selectrandom,                     // add random vest from _vest array at top of script
_backpack call bis_fnc_selectrandom,                 // add random backpack from _backpack array at top of script
[                                                    // add magazines 
["rhs_30Rnd_545x39_AK", 9],
["RH_8Rnd_9x18_Mak", 5],
["HandGrenade",5],
["smokeshell", 0],
["smokeshellred", 0],
["smokeshellpurple", 0]
],
['rhs_weap_ak74m_2mag_camo', _pistol],               // add primary weapon, add _pistol defined at top
["rhs_acc_tgpa","RH_pmsd"],                          // add weapon attachments
["firstaidkit"],                                     // add items
["rhs_balaclava1_olive"] + _assigneditems            // assigned items
];
};
 
// Operator
case "fox_opfor_sf_operator": {
[
_headgear call bis_fnc_selectrandom,
_uniform,
_vest call bis_fnc_selectrandom,
_backpack call bis_fnc_selectrandom,
[
["rhs_30Rnd_545x39_AK", 9],
["RH_8Rnd_9x18_Mak", 5],
["HandGrenade",5],
["smokeshell", 0],
["smokeshellred", 0],
["smokeshellpurple", 0]
],
['rhs_weap_ak74m_2mag_camo', _pistol],
["rhs_acc_tgpa","RH_pmsd"],
["firstaidkit"],
["rhs_balaclava"] + _assigneditems
];
};
 
// Medic
case "fox_opfor_sf_medic": {
[
_headgear call bis_fnc_selectrandom,
_uniform,
_vest call bis_fnc_selectrandom,
"FOX_carryall_grn",
[
["rhs_30Rnd_545x39_AK", 9],
["RH_8Rnd_9x18_Mak", 5],
["HandGrenade",5],
["smokeshell", 0],
["smokeshellred", 0],
["smokeshellpurple", 0]
],
['rhs_weap_ak74m_2mag_camo', _pistol],
["rhs_acc_tgpa","RH_pmsd"],
["medikit"],
[] + _assigneditems
];
};
 
// Do not edit below this line
default {[]};
};
 
if (count _state == 0) exitwith {};
 
removeallweapons _unit;
removeallitems _unit;
removeallassigneditems _unit;
removeheadgear _unit;
removebackpack _unit;
removeuniform _unit;
removevest _unit;
removegoggles _unit;
 
 
 
 
{
(_state select _foreachindex) call _x;
} foreach [
{ _unit addheadgear _this; },
{ _unit forceadduniform _this; },
{ _unit addvest _this; },
{ _unit addbackpack _this; },
{
{
for "_i" from 0 to (_x select 1) do {
_unit addmagazine (_x select 0);
}
} foreach _this;
},
{
{
_unit addweapon _x;
} foreach _this;
 
if (count _this > 0) then {
_unit selectweapon (_this select 0);
};
},
{
{
_unit addprimaryweaponitem _x;
} foreach _this;
},
{
{
_unit additem _x;
} foreach _this;
},
{
{
_unit additem _x;
_unit assignitem _x;
} foreach _this;
}
];

its simple once you understand it. it first removes everything the soldier has and then adds what you define.

note that ["rhs_30Rnd_545x39_AK", 9], will actually give you 10 mags, dont know why this is.

 

seems the proper structure of the script is lost, if you want it fixed let me know.

 

also when changing the classnames you cannot have any capital letters otherwise it wont work. recommend the use of -showscripterrors as a startup parameter if you are going to start playing with scripts...

Share this post


Link to post
Share on other sites

Thank you so much guys!!It is great to see that there are many people willing to help others.

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

×