AdirB 18 Posted January 15, 2017 Hello, the script gives gear to units, but it also sometimes (randomly) doesn't for a few players. The script works with case switching. //null = [unit name,"faction","role"]execVM "bgs.sqf"; _unit = (_this select 0); if (!local _unit) exitWith {}; _unit_faction = (_this select 1); _combat_role = (_this select 2); //BLUEFOR _bluefor_standard_helmets_array = ["UNS_M1_3A", "UNS_M1_5A", "UNS_M1_7A", "UNS_M1_8A", "UNS_M1_4A", "UNS_HP_Helmet"]; _bluefor_uniforms_array = ["UNS_ARMY_BDU_1stCav65pv2", "UNS_ARMY_BDU_1stCav65cpl", "UNS_ARMY_BDU_1stCav651stlt", "UNS_ARMY_BDU_1stCavFlakcpt", "UNS_ARMY_BDU_1stCav65pfc", "UNS_ARMY_BDU_1stCav65ssg", "UNS_ARMY_BDU_1stCavFlaksgt"]; _bluefor_standard_vests_array = ["UNS_M1956_A9", "UNS_M1956_A3", "UNS_M1956_A2", "UNS_M1956_P1", "UNS_M1956_A11", "UNS_M1956_A7"]; _bluefor_standard_backpacks_array = ["UNS_Alice_F9", "UNS_Alice_6", "UNS_Alice_F6", "UNS_Alice_5"]; _bluefor_standard_rifles_array = ["uns_m16"]; _bluefor_standard_handguns_array = ["uns_m1911", "uns_38spec"]; _bluefor_mg_array = ["uns_m60"]; _bluefor_at_array = ["uns_m72"]; _bluefor_rifle_attachments_array = ["uns_s_M16"]; _bluefor_magazines_array = ["uns_m1911mag", "uns_20Rnd_556x45_Stanag", "uns_m72rocket", "uns_m60mag", "uns_38specmag"]; _bluefor_radio_backpacks_array = ["tf_prc77"]; _bluefor_at_backpacks_array = ["UNS_Alice_3"]; _bluefor_radios_array = ["anprc90"]; _bluefor_medical_bandages = ["ACE_elasticBandage", "ACE_quikclot", "ACE_packingBandage"]; _bluefor_medical_items = ["ACE_tourniquet", "ACE_salineIV_500", "ACE_epinephrine", "ACE_morphine", "ACE_adenosine", "ACE_surgicalKit"]; _bluefor_standard_items = ["ItemMap", "ItemCompass", "ItemWatch", "ACE_EarPlugs", "ACE_Clacker", "ACE_DefusalKit", "uns_item_zippo", "ACE_CableTie"]; _bluefor_explosives_array = ["DemoCharge_Remote_Mag", "SatchelCharge_Remote_Mag"]; _bluefor_grenade_array = ["uns_m61gren"]; _bluefor_smoke_grenade_array = ["uns_m18Yellow", "uns_m18red", "uns_m18Blue"]; _bino = "Binocular"; //removing all gear removeAllWeapons _unit; removeAllItems _unit; removeAllAssignedItems _unit; removeUniform _unit; removeVest _unit; removeBackpack _unit; removeHeadgear _unit; removeGoggles _unit; ///////////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////BLUEFOR/////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////////// if (_unit_faction == "bluefor") then { switch (_combat_role) do { //hint format ["%1%2", _combat_role, _unit_faction]; //Platoon Leader case "PLTL": { //uniform, vest, helmet _unit addHeadgear (_bluefor_standard_helmets_array select 4); _unit addBackpack (_bluefor_radio_backpacks_array select 0); _unit addVest (_bluefor_standard_vests_array select 2); _unit forceAddUniform (_bluefor_uniforms_array select 2); //Weapons + Magazines _unit addWeapon (_bluefor_standard_rifles_array select 0); _unit addWeapon (_bluefor_standard_handguns_array select 0); for "_i" from 1 to 2 do {_unit addItemToVest (_bluefor_magazines_array select 0);}; for "_i" from 1 to 12 do {_unit addItemToVest (_bluefor_magazines_array select 1);}; _unit addWeapon _bino; //Grenades _unit addItemToBackpack (_bluefor_grenade_array select 0); _unit addItemToBackpack (_bluefor_smoke_grenade_array select 0); _unit addItemToBackpack (_bluefor_smoke_grenade_array select 1); _unit addItemToBackpack (_bluefor_smoke_grenade_array select 2); //Medical Items for "_i" from 1 to 5 do {_unit addItemToUniform (_bluefor_medical_bandages select 0);}; for "_i" from 1 to 5 do {_unit addItemToUniform (_bluefor_medical_bandages select 1);}; for "_i" from 1 to 5 do {_unit addItemToUniform (_bluefor_medical_bandages select 2);}; _unit addItemToUniform (_bluefor_medical_items select 0); _unit addItemToUniform (_bluefor_medical_items select 1); //Explosives for "_i" from 1 to 2 do {_unit addItemToBackpack (_bluefor_explosives_array select 0);}; _unit addItemToBackpack (_bluefor_explosives_array select 1); //Uniform Items _unit addItemToUniform (_bluefor_standard_items select 4); _unit addItemToUniform (_bluefor_standard_items select 5); _unit addItemToUniform (_bluefor_standard_items select 6); _unit addItemToUniform (_bluefor_rifle_attachments_array select 0); }; //Radio operators case "RTO": { //uniform, vest, helmet _unit addHeadgear (_bluefor_standard_helmets_array select 3); _unit addBackpack (_bluefor_radio_backpacks_array select 0); _unit addVest (_bluefor_standard_vests_array select 1); _unit forceAddUniform (_bluefor_uniforms_array select 1); //Weapons + Magazines _unit addWeapon (_bluefor_standard_rifles_array select 0); _unit addWeapon (_bluefor_standard_handguns_array select 0); for "_i" from 1 to 2 do {_unit addItemToVest (_bluefor_magazines_array select 0);}; for "_i" from 1 to 9 do {_unit addItemToVest (_bluefor_magazines_array select 1);}; _unit addWeapon _bino; //Grenades _unit addItemToBackpack (_bluefor_grenade_array select 0); _unit addItemToBackpack (_bluefor_smoke_grenade_array select 0); _unit addItemToBackpack (_bluefor_smoke_grenade_array select 1); _unit addItemToBackpack (_bluefor_smoke_grenade_array select 2); //Medical Items for "_i" from 1 to 5 do {_unit addItemToUniform (_bluefor_medical_bandages select 0);}; for "_i" from 1 to 5 do {_unit addItemToUniform (_bluefor_medical_bandages select 1);}; for "_i" from 1 to 5 do {_unit addItemToUniform (_bluefor_medical_bandages select 2);}; _unit addItemToUniform (_bluefor_medical_items select 0); _unit addItemToUniform (_bluefor_medical_items select 1); //Explosives for "_i" from 1 to 2 do {_unit addItemToBackpack (_bluefor_explosives_array select 0);}; _unit addItemToBackpack (_bluefor_explosives_array select 1); //Uniform Items _unit addItemToUniform (_bluefor_standard_items select 4); _unit addItemToUniform (_bluefor_standard_items select 5); _unit addItemToUniform (_bluefor_standard_items select 6); _unit addItemToUniform (_bluefor_rifle_attachments_array select 0); }; //Platoon Medic (SEAN) case "PLTMEDIC": { //uniform, vest, helmet _unit addHeadgear (_bluefor_standard_helmets_array select 2); _unit addBackpack (_bluefor_standard_backpacks_array select 0); _unit addVest (_bluefor_standard_vests_array select 5); _unit forceAddUniform (_bluefor_uniforms_array select 6); //Weapons + Magazines _unit addWeapon (_bluefor_standard_rifles_array select 0); _unit addWeapon (_bluefor_standard_handguns_array select 0); for "_i" from 1 to 2 do {_unit addItemToBackpack (_bluefor_magazines_array select 0);}; for "_i" from 1 to 9 do {_unit addItemToVest (_bluefor_magazines_array select 1);}; _unit addWeapon _bino; //Grenades _unit addItemToVest (_bluefor_grenade_array select 0); _unit addItemToVest (_bluefor_smoke_grenade_array select 0); _unit addItemToVest (_bluefor_smoke_grenade_array select 1); _unit addItemToVest (_bluefor_smoke_grenade_array select 2); _unit addItemToBackpack (_bluefor_grenade_array select 0); _unit addItemToBackpack (_bluefor_smoke_grenade_array select 0); _unit addItemToBackpack (_bluefor_smoke_grenade_array select 1); _unit addItemToBackpack (_bluefor_smoke_grenade_array select 2); //Medical Items for "_i" from 1 to 30 do {_unit addItemToBackpack (_bluefor_medical_bandages select 0);}; for "_i" from 1 to 20 do {_unit addItemToBackpack (_bluefor_medical_bandages select 1);}; for "_i" from 1 to 35 do {_unit addItemToBackpack (_bluefor_medical_bandages select 2);}; for "_i" from 1 to 5 do {_unit addItemToBackpack (_bluefor_medical_items select 0);}; for "_i" from 1 to 6 do {_unit addItemToBackpack (_bluefor_medical_items select 1);}; for "_i" from 1 to 15 do {_unit addItemToBackpack (_bluefor_medical_items select 2);}; for "_i" from 1 to 15 do {_unit addItemToBackpack (_bluefor_medical_items select 3);}; for "_i" from 1 to 15 do {_unit addItemToBackpack (_bluefor_medical_items select 4);}; for "_i" from 1 to 3 do {_unit addItemToBackpack (_bluefor_medical_items select 5);}; //Explosives //NONE //Uniform Items for "_i" from 1 to 4 do {_unit addItemToUniform (_bluefor_magazines_array select 1);}; _unit addItemToUniform (_bluefor_rifle_attachments_array select 0); }; //Fireteam Leaders case "FTL": { //uniform, vest, helmet _unit addHeadgear (_bluefor_standard_helmets_array select 1); _unit addBackpack (_bluefor_standard_backpacks_array select 3); _unit addVest (_bluefor_standard_vests_array select 1); _unit forceAddUniform (_bluefor_uniforms_array select 5); //Weapons + Magazines _unit addWeapon (_bluefor_standard_rifles_array select 0); _unit addWeapon (_bluefor_standard_handguns_array select 0); for "_i" from 1 to 2 do {_unit addItemToVest (_bluefor_magazines_array select 0);}; for "_i" from 1 to 9 do {_unit addItemToVest (_bluefor_magazines_array select 1);}; for "_i" from 1 to 4 do {_unit addItemToVest (_bluefor_magazines_array select 1);}; _unit addWeapon _bino; //Grenades _unit addItemToBackpack (_bluefor_grenade_array select 0); _unit addItemToBackpack (_bluefor_smoke_grenade_array select 0); _unit addItemToBackpack (_bluefor_smoke_grenade_array select 1); _unit addItemToBackpack (_bluefor_smoke_grenade_array select 2); //Medical Items for "_i" from 1 to 5 do {_unit addItemToUniform (_bluefor_medical_bandages select 0);}; for "_i" from 1 to 5 do {_unit addItemToUniform (_bluefor_medical_bandages select 1);}; for "_i" from 1 to 5 do {_unit addItemToUniform (_bluefor_medical_bandages select 2);}; _unit addItemToUniform (_bluefor_medical_items select 0); _unit addItemToUniform (_bluefor_medical_items select 1); //Explosives for "_i" from 1 to 2 do {_unit addItemToBackpack (_bluefor_explosives_array select 0);}; _unit addItemToBackpack (_bluefor_explosives_array select 1); //Uniform Items _unit addItemToUniform (_bluefor_standard_items select 4); _unit addItemToUniform (_bluefor_standard_items select 5); _unit addItemToUniform (_bluefor_standard_items select 6); _unit addItemToUniform (_bluefor_rifle_attachments_array select 0); }; //Basic Riflemen case "RIFLEMAN": { //uniform, vest, helmet _unit addHeadgear (_bluefor_standard_helmets_array select 0); _unit addBackpack (_bluefor_standard_backpacks_array select 2); _unit addVest (_bluefor_standard_vests_array select 0); _unit forceAddUniform (_bluefor_uniforms_array select 0); //Weapons + Magazines _unit addWeapon (_bluefor_standard_rifles_array select 0); _unit addWeapon (_bluefor_standard_handguns_array select 0); for "_i" from 1 to 2 do {_unit addItemToVest (_bluefor_magazines_array select 0);}; for "_i" from 1 to 9 do {_unit addItemToVest (_bluefor_magazines_array select 1);}; for "_i" from 1 to 10 do {_unit addItemToBackpack (_bluefor_magazines_array select 1);}; //Grenades _unit addItemToBackpack (_bluefor_grenade_array select 0); _unit addItemToBackpack (_bluefor_smoke_grenade_array select 0); _unit addItemToBackpack (_bluefor_smoke_grenade_array select 1); _unit addItemToBackpack (_bluefor_smoke_grenade_array select 2); //Medical Items for "_i" from 1 to 5 do {_unit addItemToUniform (_bluefor_medical_bandages select 0);}; for "_i" from 1 to 5 do {_unit addItemToUniform (_bluefor_medical_bandages select 1);}; for "_i" from 1 to 5 do {_unit addItemToUniform (_bluefor_medical_bandages select 2);}; _unit addItemToUniform (_bluefor_medical_items select 0); _unit addItemToUniform (_bluefor_medical_items select 1); //Explosives _unit addItemToBackpack (_bluefor_explosives_array select 0); //Uniform Items _unit addItemToUniform (_bluefor_rifle_attachments_array select 0); for "_i" from 1 to 4 do {_unit addItemToUniform (_bluefor_magazines_array select 1);}; }; //AT Riflemen case "ATRIFLEMAN": { //uniform, vest, helmet _unit addHeadgear (_bluefor_standard_helmets_array select 0); _unit addBackpack (_bluefor_at_backpacks_array select 0); _unit addVest (_bluefor_standard_vests_array select 0); _unit forceAddUniform (_bluefor_uniforms_array select 0); //Weapons + Magazines _unit addWeapon (_bluefor_standard_rifles_array select 0); _unit addWeapon (_bluefor_standard_handguns_array select 0); _unit addWeapon (_bluefor_at_array select 0); for "_i" from 1 to 2 do {_unit addItemToBackpack (_bluefor_magazines_array select 0);}; for "_i" from 1 to 9 do {_unit addItemToVest (_bluefor_magazines_array select 1);}; for "_i" from 1 to 4 do {_unit addItemToBackpack (_bluefor_magazines_array select 1);}; for "_i" from 1 to 10 do {_unit addItemToBackpack (_bluefor_magazines_array select 1);}; _unit addItemToBackpack (_bluefor_magazines_array select 2); //Grenades _unit addItemToBackpack (_bluefor_grenade_array select 0); _unit addItemToBackpack (_bluefor_smoke_grenade_array select 0); _unit addItemToBackpack (_bluefor_smoke_grenade_array select 1); _unit addItemToBackpack (_bluefor_smoke_grenade_array select 2); //Medical Items for "_i" from 1 to 5 do {_unit addItemToUniform (_bluefor_medical_bandages select 0);}; for "_i" from 1 to 5 do {_unit addItemToUniform (_bluefor_medical_bandages select 1);}; for "_i" from 1 to 5 do {_unit addItemToUniform (_bluefor_medical_bandages select 2);}; _unit addItemToUniform (_bluefor_medical_items select 0); _unit addItemToUniform (_bluefor_medical_items select 1); //Explosives //NONE //Uniform Items _unit addItemToUniform (_bluefor_rifle_attachments_array select 0); }; //Fireteam Medic case "FTMEDIC": { //uniform, vest, helmet _unit addHeadgear (_bluefor_standard_helmets_array select 2); _unit addBackpack (_bluefor_standard_backpacks_array select 0); _unit addVest (_bluefor_standard_vests_array select 5); _unit forceAddUniform (_bluefor_uniforms_array select 6); //Weapons + Magazines _unit addWeapon (_bluefor_standard_rifles_array select 0); _unit addWeapon (_bluefor_standard_handguns_array select 0); for "_i" from 1 to 2 do {_unit addItemToBackpack (_bluefor_magazines_array select 0);}; for "_i" from 1 to 9 do {_unit addItemToVest (_bluefor_magazines_array select 1);}; //Grenades _unit addItemToVest (_bluefor_grenade_array select 0); _unit addItemToVest (_bluefor_smoke_grenade_array select 0); _unit addItemToVest (_bluefor_smoke_grenade_array select 1); _unit addItemToVest (_bluefor_smoke_grenade_array select 2); _unit addItemToBackpack (_bluefor_grenade_array select 0); _unit addItemToBackpack (_bluefor_smoke_grenade_array select 0); _unit addItemToBackpack (_bluefor_smoke_grenade_array select 1); _unit addItemToBackpack (_bluefor_smoke_grenade_array select 2); //Medical Items for "_i" from 1 to 15 do {_unit addItemToBackpack (_bluefor_medical_bandages select 0);}; for "_i" from 1 to 15 do {_unit addItemToBackpack (_bluefor_medical_bandages select 1);}; for "_i" from 1 to 15 do {_unit addItemToBackpack (_bluefor_medical_bandages select 2);}; for "_i" from 1 to 3 do {_unit addItemToBackpack (_bluefor_medical_items select 0);}; for "_i" from 1 to 1 do {_unit addItemToBackpack (_bluefor_medical_items select 1);}; for "_i" from 1 to 5 do {_unit addItemToBackpack (_bluefor_medical_items select 2);}; for "_i" from 1 to 5 do {_unit addItemToBackpack (_bluefor_medical_items select 3);}; for "_i" from 1 to 5 do {_unit addItemToBackpack (_bluefor_medical_items select 4);}; //Explosives //NONE //Uniform Items _unit addItemToUniform (_bluefor_rifle_attachments_array select 0); for "_i" from 1 to 4 do {_unit addItemToUniform (_bluefor_magazines_array select 1);}; }; //Machinegunners case "MG": { //uniform, vest, helmet _unit addHeadgear (_bluefor_standard_helmets_array select 0); _unit addBackpack (_bluefor_standard_backpacks_array select 2); _unit addVest (_bluefor_standard_vests_array select 4); _unit forceAddUniform (_bluefor_uniforms_array select 4); //Weapons + Magazines _unit addWeapon (_bluefor_mg_array select 0); _unit addWeapon (_bluefor_standard_handguns_array select 0); for "_i" from 1 to 2 do {_unit addItemToVest (_bluefor_magazines_array select 0);}; for "_i" from 1 to 3 do {_unit addItemToBackpack (_bluefor_magazines_array select 3);}; for "_i" from 1 to 3 do {_unit addItemToVest (_bluefor_magazines_array select 3);}; //Grenades for "_i" from 1 to 2 do {_unit addItemToVest (_bluefor_grenade_array select 0);}; for "_i" from 1 to 2 do {_unit addItemToBackpack (_bluefor_grenade_array select 0);}; _unit addItemToBackpack (_bluefor_smoke_grenade_array select 0); _unit addItemToBackpack (_bluefor_smoke_grenade_array select 1); _unit addItemToBackpack (_bluefor_smoke_grenade_array select 2); //Medical Items for "_i" from 1 to 5 do {_unit addItemToUniform (_bluefor_medical_bandages select 0);}; for "_i" from 1 to 5 do {_unit addItemToUniform (_bluefor_medical_bandages select 1);}; for "_i" from 1 to 5 do {_unit addItemToUniform (_bluefor_medical_bandages select 2);}; _unit addItemToUniform (_bluefor_medical_items select 0); _unit addItemToUniform (_bluefor_medical_items select 1); //Explosives //NONE //Uniform Items //NONE }; //Pilots case "PILOT": { //uniform, vest, helmet _unit addHeadgear (_bluefor_standard_helmets_array select 5); _unit addVest (_bluefor_standard_vests_array select 3); _unit forceAddUniform (_bluefor_uniforms_array select 3); //Weapons + Magazines _unit addWeapon (_bluefor_standard_handguns_array select 1); for "_i" from 1 to 5 do {_unit addItemToVest (_bluefor_magazines_array select 4);}; _unit addWeapon _bino; //Grenades _unit addItemToVest (_bluefor_grenade_array select 0); _unit addItemToVest (_bluefor_smoke_grenade_array select 0); _unit addItemToVest (_bluefor_smoke_grenade_array select 1); _unit addItemToVest (_bluefor_smoke_grenade_array select 2); //Medical Items for "_i" from 1 to 5 do {_unit addItemToUniform (_bluefor_medical_bandages select 0);}; for "_i" from 1 to 5 do {_unit addItemToUniform (_bluefor_medical_bandages select 1);}; for "_i" from 1 to 5 do {_unit addItemToUniform (_bluefor_medical_bandages select 2);}; _unit addItemToUniform (_bluefor_medical_items select 0); _unit addItemToUniform (_bluefor_medical_items select 1); //Explosives //NONE //Uniform Items //NONE //Radio _unit linkItem (_bluefor_radios_array select 0); }; }; //Items To Everyone _unit removePrimaryWeaponItem (_bluefor_magazines_array select 1); _unit removePrimaryWeaponItem (_bluefor_magazines_array select 3); _unit removePrimaryWeaponItem (_bluefor_magazines_array select 4); _unit linkItem (_bluefor_standard_items select 0); _unit linkItem (_bluefor_standard_items select 1); _unit linkItem (_bluefor_standard_items select 2); _unit addItemToUniform (_bluefor_standard_items select 3); _unit addItemToBackpack (_bluefor_standard_items select 8); }; Share this post Link to post Share on other sites
dchan200 18 Posted January 16, 2017 Sounds like a timing problem. I got a few questions Those players that do not get the proper loadout, are they JIP? Instead of the proper loadout, what do they get? Share this post Link to post Share on other sites
AdirB 18 Posted January 16, 2017 9 hours ago, dchan200 said: Sounds like a timing problem. I got a few questions Those players that do not get the proper loadout, are they JIP? Instead of the proper loadout, what do they get? I don't really know what JIP is but the bug happens when theres alot of players and it happens to players who are joining in the middle of the game or to players who are reconnecting. Edit: oh JIP is Join In Progress lol Instead of the proper gear they only get their helmets and their primary weapons. Which also comes from the script and its kinda weird too. Share this post Link to post Share on other sites
FirstPanic 39 Posted January 16, 2017 To manage the timing you can put something like a queue in front of your script (e.g. a simple array which contains player ID and role etc.) and than have a simple queue manager (e.g. a script which looks every 5 seconds in the queue) to check if there is a loadout requested. FirstPanic Share this post Link to post Share on other sites
AdirB 18 Posted January 17, 2017 I get this error Quote 20:02:50 Error in expression <leep _delay; switch (player) do { case PLT_leader: {[player,"BLUEFOR","PLTL"]ex> 20:02:50 Error position: <PLT_leader: {[player,"BLUEFOR","PLTL"]ex> 20:02:50 Error Undefined variable in expression: plt_leader 20:02:50 File mpmissions\__CUR_MP.DaKrong\mission_scripts\manage_gear.sqf, line 9 That's the script _delay = 5; waitUntil { !isNull player }; sleep _delay; switch (player) do { case PLT_leader: {[player,"BLUEFOR","PLTL"]execVM "mission_scripts\gear_script\bgs.sqf";}; case PLT_rto: {[player,"BLUEFOR","RTO"]execVM "mission_scripts\gear_script\bgs.sqf";}; case PLT_medic: {[player,"BLUEFOR","PLTMEDIC"]execVM "mission_scripts\gear_script\bgs.sqf";}; case FTL_alpha: {[player,"BLUEFOR","FTL"]execVM "mission_scripts\gear_script\bgs.sqf";}; case RTO_alpha: {[player,"BLUEFOR","RTO"]execVM "mission_scripts\gear_script\bgs.sqf";}; case RIFLEMAN_alpha: {[player,"BLUEFOR","RIFLEMAN"]execVM "mission_scripts\gear_script\bgs.sqf";}; case ATRIFLEMAN_alpha: {[player,"BLUEFOR","ATRIFLEMAN"]execVM "mission_scripts\gear_script\bgs.sqf";}; case MEDIC_alpha: {[player,"BLUEFOR","FTMEDIC"]execVM "mission_scripts\gear_script\bgs.sqf";}; case MG_alpha: {[player,"BLUEFOR","MG"]execVM "mission_scripts\gear_script\bgs.sqf";}; case FTL_bravo: {[player,"BLUEFOR","FTL"]execVM "mission_scripts\gear_script\bgs.sqf";}; case RTO_bravo: {[player,"BLUEFOR","RTO"]execVM "mission_scripts\gear_script\bgs.sqf";}; case RIFLEMAN_bravo: {[player,"BLUEFOR","RIFLEMAN"]execVM "mission_scripts\gear_script\bgs.sqf";}; case ATRIFLEMAN_bravo: {[player,"BLUEFOR","ATRIFLEMAN"]execVM "mission_scripts\gear_script\bgs.sqf";}; case MEDIC_bravo: {[player,"BLUEFOR","FTMEDIC"]execVM "mission_scripts\gear_script\bgs.sqf";}; case MG_bravo: {[player,"BLUEFOR","MG"]execVM "mission_scripts\gear_script\bgs.sqf";}; case FTL_charlie: {[player,"BLUEFOR","FTL"]execVM "mission_scripts\gear_script\bgs.sqf";}; case RTO_charlie: {[player,"BLUEFOR","RTO"]execVM "mission_scripts\gear_script\bgs.sqf";}; case RIFLEMAN_charlie: {[player,"BLUEFOR","RIFLEMAN"]execVM "mission_scripts\gear_script\bgs.sqf";}; case ATRIFLEMAN_charlie: {[player,"BLUEFOR","ATRIFLEMAN"]execVM "mission_scripts\gear_script\bgs.sqf";}; case MEDIC_charlie: {[player,"BLUEFOR","FTMEDIC"]execVM "mission_scripts\gear_script\bgs.sqf";}; case MG_charlie: {[player,"BLUEFOR","MG"]execVM "mission_scripts\gear_script\bgs.sqf";}; case Reserve_1: {[player,"BLUEFOR","RIFLEMAN"]execVM "mission_scripts\gear_script\bgs.sqf";}; case Reserve_2: {[player,"BLUEFOR","RIFLEMAN"]execVM "mission_scripts\gear_script\bgs.sqf";}; case Reserve_3: {[player,"BLUEFOR","RIFLEMAN"]execVM "mission_scripts\gear_script\bgs.sqf";}; case Reserve_4: {[player,"BLUEFOR","RIFLEMAN"]execVM "mission_scripts\gear_script\bgs.sqf";}; case Pilot_1: {[player,"BLUEFOR","PILOT"]execVM "mission_scripts\gear_script\bgs.sqf";}; case Pilot_2: {[player,"BLUEFOR","PILOT"]execVM "mission_scripts\gear_script\bgs.sqf";}; case Pilot_3: {[player,"BLUEFOR","PILOT"]execVM "mission_scripts\gear_script\bgs.sqf";}; case Pilot_4: {[player,"BLUEFOR","PILOT"]execVM "mission_scripts\gear_script\bgs.sqf";}; }; PLT_leader is defined, I triple checked it. Share this post Link to post Share on other sites
dchan200 18 Posted January 17, 2017 Could you try replacing your execVM with call? I have had similar issues with assigning loadouts sometime ago and that seemed to fix it for me. Take a look at killzone_kid's post here: Share this post Link to post Share on other sites
AdirB 18 Posted January 17, 2017 10 hours ago, dchan200 said: Could you try replacing your execVM with call? I have had similar issues with assigning loadouts sometime ago and that seemed to fix it for me. Take a look at killzone_kid's post here: I never used this before, can you please confirm that it's correct? [unit name,"faction","role"] call compile preprocessFile "bgs.sqf"; Share this post Link to post Share on other sites
theend3r 83 Posted January 17, 2017 15 minutes ago, SoOCoOL said: I never used this before, can you please confirm that it's correct? [unit name,"faction","role"] call compile preprocessFile "bgs.sqf"; You only call that once. //init or preInit I guess fnc_bgs = call compile preprocessFile "bgs.sqf" //then each time exec by [unit name, "faction", "role"] call fnc_bgs Share this post Link to post Share on other sites
AdirB 18 Posted January 17, 2017 18 minutes ago, theend3r said: You only call that once. //init or preInit I guess fnc_bgs = call compile preprocessFile "bgs.sqf" //then each time exec by [unit name, "faction", "role"] call fnc_bgs Thanks! Where do I use the call functions? In the unit's init or maybe in initplayerloca? Share this post Link to post Share on other sites
theend3r 83 Posted January 17, 2017 50 minutes ago, SoOCoOL said: Thanks! Where do I use the call functions? In the unit's init or maybe in initplayerloca? In the initServer.sqf or anywhere that runs only once and before you need to use the function. Share this post Link to post Share on other sites
Boerstil 8 Posted January 17, 2017 waitUntil {!isNull player}; waitUntil {local player}; waitUntil {alive player}; Had the same issue. this fixed it for me. 1 Share this post Link to post Share on other sites
dchan200 18 Posted January 17, 2017 8 hours ago, SoOCoOL said: I never used this before, can you please confirm that it's correct? [unit name,"faction","role"] call compile preprocessFile "bgs.sqf"; @theend3r If you were to put this in each unit's init would it actually be compiled N times for each player? I have not used compile/preprocessFile in this manner before but that would make sense (and bad). @SoOCoOL Sorry for this confusion. I linked killzone_kid's post thinking it would be easier compared to the way I do it, but maybe not. Instead, I added my function to description.ext (modified for your file): description.ext class CfgFunctions { class soocool { class loadout { class assignLoadout { file = "bgs.sqf"; }; }; }; }; Unit init box: [unit name,"faction","role"] call soocool_fnc_assignLoadout; Like you, I only check if the unit is local and I have not run into any problem with gear not being assigned doing it this way. No guarantees though since I'm sure your mission scale is much larger than mines. Share this post Link to post Share on other sites
theend3r 83 Posted January 17, 2017 58 minutes ago, dchan200 said: @theend3r If you were to put this in each unit's init would it actually be compiled N times for each player? I have not used compile/preprocessFile in this manner before but that would make sense (and bad). @SoOCoOL Sorry for this confusion. I linked killzone_kid's post thinking it would be easier compared to the way I do it, but maybe not. Instead, I added my function to description.ext (modified for your file): description.ext class CfgFunctions { class soocool { class loadout { class assignLoadout { file = "bgs.sqf"; }; }; }; }; Unit init box: [unit name,"faction","role"] call soocool_fnc_assignLoadout; Like you, I only check if the unit is local and I have not run into any problem with gear not being assigned doing it this way. No guarantees though since I'm sure your mission scale is much larger than mines. You don't need that config at all, you can preprocess any file. fnc_bgs = call compile preprocessFile "bgs.sqf" is the same as fnc_bgs = {script contents of bgs.sqf}, it reads from a file and defines it as a function. Just do what I wrote above and it should work. But yes, your approach should work, too, but I like short fucntion names and a description.ext as short as possible. Share this post Link to post Share on other sites
dchan200 18 Posted January 17, 2017 @theend3r I understand that you can compile/preprocess any file into a function, but are you sure it works in this scenario due to the initialization order? OP and I are calling the function from the unit's init line and that is done before any of the scripts (init.sqf, etc) fires. Also, looking back at this post, the first line does not make sense. Typo? 9 hours ago, theend3r said: You only call that once. //init or preInit I guess fnc_bgs = call compile preprocessFile "bgs.sqf" //then each time exec by [unit name, "faction", "role"] call fnc_bgs Share this post Link to post Share on other sites
theend3r 83 Posted January 17, 2017 6 minutes ago, dchan200 said: @theend3r I understand that you can compile/preprocess any file into a function, but are you sure it works in this scenario due to the initialization order? OP and I are calling the function from the unit's init line and that is done before any of the scripts (init.sqf, etc) fires. Also, looking back at this post, the first line does not make sense. Typo? Yes, you're right in both cases. The call shouldn't be there in my example and since you use object init then you need to predefine the function in a config, true. I got confused as I never use object init fields (except for singular unique objects) since it's generally a bad practice as it's a pain to change them. It's better to do everything from (server)init.sqf by collecting whatever you need in an array and working with it from there. Share this post Link to post Share on other sites
dchan200 18 Posted January 18, 2017 3 minutes ago, theend3r said: Yes, you're right in both cases. The call shouldn't be there in my example and since you use object init then you need to predefine the function in a config, true. I got confused as I never use object init fields (except for singular unique objects) since it's generally a bad practice as it's a pain to change them. It's better to do everything from (server)init.sqf by collecting whatever you need in an array and working with it from there. I just get lazy sometimes (old habits), but I agree with you. @SoOCoOL Let us know how it works out and we'll go from there. Share this post Link to post Share on other sites
AdirB 18 Posted January 18, 2017 18 hours ago, theend3r said: Yes, you're right in both cases. The call shouldn't be there in my example and since you use object init then you need to predefine the function in a config, true. I got confused as I never use object init fields (except for singular unique objects) since it's generally a bad practice as it's a pain to change them. It's better to do everything from (server)init.sqf by collecting whatever you need in an array and working with it from there. 18 hours ago, dchan200 said: I just get lazy sometimes (old habits), but I agree with you. @SoOCoOL Let us know how it works out and we'll go from there. So I need to remove the call from the first line? It suppose to be like this? fnc_bgs = compile preprocessFile "bgs.sqf" Share this post Link to post Share on other sites
AdirB 18 Posted January 18, 2017 18 hours ago, dchan200 said: I just get lazy sometimes (old habits), but I agree with you. @SoOCoOL Let us know how it works out and we'll go from there. 18 hours ago, theend3r said: Yes, you're right in both cases. The call shouldn't be there in my example and since you use object init then you need to predefine the function in a config, true. I got confused as I never use object init fields (except for singular unique objects) since it's generally a bad practice as it's a pain to change them. It's better to do everything from (server)init.sqf by collecting whatever you need in an array and working with it from there. Also, I didn't understand why it would be wrong to use @theend3r's method. I'm using if (!local _unit) exitWith {}; in my script, so it will run locally on each unit if I call the function from the unit's init. Share this post Link to post Share on other sites
dchan200 18 Posted January 18, 2017 On 1/17/2017 at 1:46 PM, dchan200 said: description.ext class CfgFunctions { class soocool { class loadout { class assignLoadout { file = "bgs.sqf"; }; }; }; }; Unit init box: [unit name,"faction","role"] call soocool_fnc_assignLoadout; @SoOCoOL I'll reiterate why theend3r's method will not work in this situation: initialization order. The unit init will run before any other script (init.sqf, etc) fires so the function will not be available at that point unless it is (a) defined in CfgFunctions or (b) you do what killzone_kid suggested. theend3r's posts refer to another scenario (running after unit init) which does not fit your use case. Give what I quoted above a try since this fits your use case: running from the unit init. Side note: Spoiler killzone_kid suggested using "call compile preprocessFile" in each unit init. However, I am concerned that each player would have to compile/preprocessFile N times so went with the CfgFunctions way instead. Share this post Link to post Share on other sites
AdirB 18 Posted January 19, 2017 2 hours ago, dchan200 said: @SoOCoOL I'll reiterate why theend3r's method will not work in this situation: initialization order. The unit init will run before any other script (init.sqf, etc) fires so the function will not be available at that point unless it is (a) defined in CfgFunctions or (b) you do what killzone_kid suggested. theend3r's posts refer to another scenario (running after unit init) which does not fit your use case. Give what I quoted above a try since this fits your use case: running from the unit init. Side note: Hide contents killzone_kid suggested using "call compile preprocessFile" in each unit init. However, I am concerned that each player would have to compile/preprocessFile N times so went with the CfgFunctions way instead. I tried the script in three ways: 1. Call the function in a gear generator and run the gear generator with a simple execVM from the init.sqf. The gear generator looks like that: Spoiler _delay = 5; waitUntil { !isNull player }; sleep _delay; switch (player) do { case PLT_leader: {[player, "BLUEFOR", "PLTL"] call fnc_bgs}; case PLT_rto: {[player, "BLUEFOR", "RTO"] call fnc_bgs}; case PLT_medic: {[player, "BLUEFOR", "PLTMEDIC"] call fnc_bgs}; case FTL_alpha: {[player, "BLUEFOR", "FTL"] call fnc_bgs}; case RTO_alpha: {[player, "BLUEFOR", "RTO"] call fnc_bgs}; case RIFLEMAN_alpha: {[player, "BLUEFOR", "RIFLEMAN"] call fnc_bgs}; case ATRIFLEMAN_alpha: {[player, "BLUEFOR", "ATRIFLEMAN"] call fnc_bgs}; case MEDIC_alpha: {[player, "BLUEFOR", "FTMEDIC"] call fnc_bgs}; case MG_alpha: {[player, "BLUEFOR", "MG"] call fnc_bgs}; case FTL_bravo: {[player,"BLUEFOR","FTL"] call fnc_bgs}; case RTO_bravo: {[player,"BLUEFOR","RTO"] call fnc_bgs}; case RIFLEMAN_bravo: {[player,"","RIFLEMAN"] call fnc_bgs}; case ATRIFLEMAN_bravo: {[player,"BLUEFOR","ATRIFLEMAN"] call fnc_bgs}; case MEDIC_bravo: {[player,"BLUEFOR","FTMEDIC"] call fnc_bgs}; case MG_bravo: {[player,"BLUEFOR","MG"] call fnc_bgs}; case FTL_charlie: {[player,"BLUEFOR","FTL"] call fnc_bgs}; case RTO_charlie: {[player,"BLUEFOR","RTO"] call fnc_bgs}; case RIFLEMAN_charlie: {[player,"","RIFLEMAN"] call fnc_bgs}; case ATRIFLEMAN_charlie: {[player,"BLUEFOR","ATRIFLEMAN"] call fnc_bgs}; case MEDIC_charlie: {[player,"BLUEFOR","FTMEDIC"] call fnc_bgs}; case MG_charlie: {[player,"BLUEFOR","MG"] call fnc_bgs}; case Reserve_1: {[player,"BLUEFOR","RIFLEMAN"] call fnc_bgs}; case Reserve_2: {[player,"BLUEFOR","RIFLEMAN"] call fnc_bgs}; case Reserve_3: {[player,"BLUEFOR","RIFLEMAN"] call fnc_bgs}; case Reserve_4: {[player,"BLUEFOR","RIFLEMAN"] call fnc_bgs}; case Reserve_5: {[player,"BLUEFOR","RIFLEMAN"] call fnc_bgs}; case Pilot_1: {[player,"BLUEFOR","PILOT"] call fnc_bgs}; case Pilot_2: {[player,"BLUEFOR","PILOT"] call fnc_bgs}; case Pilot_3: {[player,"BLUEFOR","PILOT"] call fnc_bgs}; case Pilot_4: {[player,"BLUEFOR","PILOT"] call fnc_bgs}; }; [/CODE] 2. Call the function from the initplayerlocal.sqf, looks the same as the gear generator. 3. Call the function from the unit's init. The three ways didn't work. The bgs.sqf isn't running at all. @dchan200, I will try your method with the CfgFunctions and update you. Share this post Link to post Share on other sites