fight9 14 Posted March 10, 2015 You are waiting for TFAR to do its work first. So, the sleep time is really indeterminable. You can also put this in the INIT.sqf to stop everyone from getting the DAGR TF_give_microdagr_to_soldier = false; Share this post Link to post Share on other sites
kOepi 10 Posted March 10, 2015 thank you fight9, I was looking for so long for that line .... ! I figured that part of my problem was that my player loadouts were missing this: waitUntil { !isNull player }; but what would be the counterpart for the AI loadouts? // 0-4 Recon Specialist Spetsnaz waitUntil { !isNull _this }; _RSF = _this select 0; _RSF spawn fnc_removeall; // clothing [_RSF,1] spawn fnc_giveHeadGear; [_RSF,3] spawn fnc_giveFaceW; [_RSF,1] spawn fnc_giveUniform; [_RSF,1] spawn fnc_giveVest; [_RSF,1] spawn fnc_giveBackPack; // items - Radio _RSF spawn fnc_giveCmps; _RSF spawn fnc_giveMS; _RSF spawn fnc_giveitems; // weapons _RSF spawn fnc_giveWVSS; _RSF spawn fnc_giveWMakS; _RSF spawn fnc_givegrensVR; // backpack content _RSF spawn fnc_giveMineRSF; _RSF spawn fnc_givegrensBPR; any help appreciated ! :D Share this post Link to post Share on other sites
zooloo75 834 Posted March 11, 2015 A reliance on using sleep for performance/optimization purposes is not good. If that's the first resort, then there are bigger issues with the code. Share this post Link to post Share on other sites
fight9 14 Posted March 11, 2015 [b]// isnt [i]_this select 0[/i] the unit?[/b] waitUntil { !isNull (_this select 0) }; Share this post Link to post Share on other sites
kOepi 10 Posted March 11, 2015 (edited) @ zooloo75 for a better resolution I put an unrealistic amount of units of the player loadouts into the editor, so like 3 platoons, 135 men. even though it looked in the beginning that sleep commands change the completion of the units I cannot confirm this with even only vests, uniform or helmets equipping to all of them seperately. I have between 5 % and 8 % failure even on that, in the editor. those profiles which are related only 3 times in the HQ are comparatevely unaffected, what I cannot confirm with the profiles that are executed like 6 times. I will try the waitUntil thing from fight 9. this is my functions.sqf // marines / (spetsnaz) loadout function fnc_removeall = { removeAllWeapons _this; removeAllItems _this; removeAllAssignedItems _this; removeUniform _this; removeVest _this; removeBackpack _this; removeHeadgear _this; removeGoggles _this; }; // 0.0051 ms // Items, Radios fnc_giveradio = { private ["_rad"]; _rad = switch (_this select 1) do { case 1:{"tf_pnr1000a_1"}; case 2:{"tf_rf7800str"}; case 3:{"tf_anprc152_19"}; default {""}; }; if (_rad == "") exitWith {false}; (_this select 0) linkitem _rad; true; }; fnc_giveMS = { for "_i" from 1 to 7 do {_this addItemToUniform "AGM_Bandage";}; for "_i" from 1 to 3 do {_this addItemToUniform "AGM_Morphine";}; for "_i" from 1 to 2 do {_this addItemToUniform "AGM_Epipen";}; _this addItemToUniform "AGM_EarBuds"; }; fnc_giveMSHM = { for "_i" from 1 to 26 do {_this addItemToBackpack "AGM_Bandage";}; for "_i" from 1 to 13 do {_this addItemToBackpack "AGM_Morphine";}; for "_i" from 1 to 13 do {_this addItemToBackpack "AGM_Epipen";}; for "_i" from 1 to 13 do {_this addItemToBackpack "AGM_Bloodbag";}; for "_i" from 1 to 4 do {_this addItemToVest "rhs_mag_an_m8hc";}; for "_i" from 1 to 6 do {_this addItemToVest "rhs_mag_m18_yellow";}; }; fnc_giveCmps = { _this linkItem "Itemcompass"; }; fnc_giveGPS = { _this linkitem "ItemGPS"; }; fnc_giveitems = { _this addweapon "binocular"; _this linkItem "ItemMap"; _this linkItem "Itemwatch"; }; // 0.00517 ms // Clothing // Clothing // Clothing fnc_giveUniform = { private ["_uni"]; _uni = switch (_this select 1) do { case 1:{"rhs_uniform_mflora_patchless"}; case 2:{"MEF_OD_WMARPAT_RM_RS"}; case 3:{"MEF_TAN_WMARPAT_RM_RS"}; case 4:{"MEF_Wood_MARPAT_RM_RS"}; case 5:{"MEF_Wood_MARPAT_RM_LS"}; case 6:{"U_B_HeliPilotCoveralls"}; default {""}; }; if (_uni == "") exitWith {false}; (_this select 0) forceaddUniform _uni; true; }; fnc_giveVest = { private ["_vest"]; _vest = switch (_this select 1) do { case 1:{"rhs_6sh92_digi"}; case 2:{"rhs_6sh92_headset"}; case 3:{"MEF_Vest_Tan_Infantry_L"}; case 4:{"MEF_Vest_Tan_Infantry"}; case 5:{"V_BandollierB_rgr"}; default {""}; }; if (_vest == "") exitWith {false}; (_this select 0) addVest _vest; true; }; fnc_giveBackPack = { private ["_BP"]; _BP = switch (_this select 1) do { case 1:{"CUP_B_ACRScout_m95"}; case 2:{"rhs_sidor"}; case 3:{"B_Kitbag_rgr"}; case 4:{"tf_mr3000"}; case 5:{"MEF_Wood_Assault"}; case 6:{"MEF_Wood_Kitbag"}; case 7:{"tf_rt1523g_big_bwmod"}; default {""}; }; if (_BP == "") exitWith {false}; (_this select 0) addBackpack _BP; true; }; // clothing headgear // clothing headgear // clothing headgear fnc_giveHeadGear = { private ["_HG"]; _HG = switch (_this select 1) do { case 1:{"H_Bandanna_sgg"}; // Bandana Sage case 2:{"H_Bandanna_khk"}; // Bandana khaki case 3:{"rhs_beanie_green"}; //EMR-summer Beanie case 4:{"rhs_fieldcap"}; // flora field cap case 5:{"rhs_fieldcap_ml"}; // mountain les field cap case 6:{"MEF_Woodland_8Point"}; // Field Cap marpat woodland case 7:{"MEF_Boonie_Wood"}; // Boonie Hat marpat woodland case 8:{"MEF_Boonie_Des"}; // Boonie Hat marpat desert case 9:{"H_Cap_grn"}; // Blue Cap for Pilot default {""}; }; if (_HG == "") exitWith {false}; (_this select 0) addHeadGear _HG; true; }; fnc_giveHeadGToUniform = { private ["_HG"]; _HG = switch (_this select 1) do { case 1:{"MEF_Desert_8Point"}; // Field Cap case 2:{"MEF_Woodland_8Point"}; // Field Cap case 3:{"rhsusf_ach_bare_headset"}; // Helmet for SL on body case 4:{"rhsusf_ach_bare_semi_headset"}; // Helmet for HQ on body case 5:{"H_PilotHelmetHeli_O"}; // Pilot Helmet for Pilot on body default {""}; }; if (_HG == "") exitWith {false}; (_this select 0) addItemToUniform _HG; true; }; // CLothing - Facewear // CLothing - Facewear // CLothing - Facewear fnc_giveFaceW = { private ["_FW"]; _FW = switch (_this select 1) do { case 1:{"G_Bandanna_tan"}; // facemask tan case 2:{"G_Bandanna_oli"}; // facemask olive case 3:{"G_Bandanna_khk"}; // facemask khaki case 4:{"G_Aviator"}; // facemask khaki default {""}; }; if (_FW == "") exitWith {false}; (_this select 0) addGoggles _FW; true; }; fnc_giveHelmet = { private ["_HM"]; _HM = switch (_this select 1) do { case 1:{"rhsusf_ach_bare_wood"}; case 2:{"rhsusf_ach_bare"}; case 3:{"rhsusf_ach_bare_des"}; case 4:{"rhsusf_ach_bare_des_headset"}; case 5:{"rhsusf_ach_bare_semi_headset"}; default {""}; }; if (_HM == "") exitWith {false}; (_this select 0) addHeadGear _HM; true; }; // Russian weapons // Russian weapons // Russian weapons fnc_giveWMaks = { _this addItemtoUniform "CUP_8Rnd_9x18_MakarovSD_M"; _this addWeapon "CUP_hgun_PB6P9"; for "_i" from 1 to 2 do {_this addItemToUniform "CUP_8Rnd_9x18_MakarovSD_M";}; _this addHandgunItem "CUP_muzzle_PB6P9"; }; fnc_giveWBizon = { for "_i" from 1 to 3 do {_this addItemToVest "CUP_64Rnd_9x19_Bizon_M";}; _this addWeapon "CUP_smg_bizon"; _this addPrimaryWeaponItem "CUP_muzzle_Bizon"; _this addPrimaryWeaponItem "CUP_optic_Kobra"; }; fnc_giveWAK74U = { _this addItemToVest "CUP_30Rnd_TE1_Green_Tracer_545x39_AK_M"; _this addItemToVest "CUP_30Rnd_TE1_Red_Tracer_545x39_AK_M"; _this addItemToVest "CUP_30Rnd_TE1_Yellow_Tracer_545x39_AK_M"; for "_i" from 1 to 4 do {_this addItemToVest "CUP_30Rnd_545x39_AK_M";}; _this addWeapon "CUP_arifle_AKS74U"; _this addPrimaryWeaponItem "CUP_optic_Kobra"; _this addPrimaryWeaponItem "CUP_muzzle_PBS4"; _this addItemToUniform "tf_microdagr"; }; fnc_giveWSVD = { for "_i" from 1 to 9 do {_this addItemToVest "rhs_10Rnd_762x54mmR_7N1";}; _this addWeapon "rhs_weap_svdp_wd"; _this addPrimaryWeaponItem "rhs_acc_pso1m2"; }; fnc_giveWVSS = { for "_i" from 1 to 7 do {_this addItemToVest "CUP_20Rnd_9x39_SP5_VSS_M";}; _this addWeapon "CUP_srifle_VSSVintorez"; _this addPrimaryWeaponItem "CUP_optic_PSO_1"; }; fnc_givegrensVR = { _this addItemToVest "rhs_mag_rgd5"; _this addItemToVest "rhs_mag_rgd5"; _this addItemToVest "rhs_mag_rdg2_white"; }; fnc_givegrensBPR = { _this addItemtoBackpack "rhs_mag_rgd5"; _this addItemToBackpack "rhs_mag_rdg2_white"; }; fnc_giveWRPG32 = { _this addItemToBackpack "RPG32_F"; _this addWeapon "launch_RPG32_F"; _this addItemToBackpack "RPG32_F"; }; fnc_giveWRPG18 = { for "_i" from 1 to 2 do {_this addItemToBackpack "CUP_RPG18_M";}; _this addWeapon "CUP_launch_RPG18"; }; // American weapons // American weapons // American weapons fnc_giveWM9 = { for "_i" from 1 to 2 do {_this addItemToVest "CUP_15Rnd_9x19_M9";}; _this addWeapon "CUP_hgun_M9"; _this additemToUniform "CUP_15Rnd_9x19_M9"; }; fnc_giveWM16_1 = { for "_i" from 1 to 7 do {_this addItemToVest "CUP_30Rnd_556x45_Stanag";}; _this addWeapon "CUP_arifle_M16A4_Base"; sleep 0.01; }; fnc_giveWM16_2 = { for "_i" from 1 to 4 do {_this addItemToVest "CUP_30Rnd_556x45_Stanag";}; for "_i" from 1 to 3 do {_this addItemToVest "CUP_30Rnd_TE1_Red_Tracer_556x45_G36";}; _this addWeapon "CUP_arifle_M16A4_Base"; _this additemToUniform "tf_microdagr"; }; fnc_giveWM16M203 = { for "_i" from 1 to 4 do {_this addItemToVest "CUP_30Rnd_556x45_Stanag";}; for "_i" from 1 to 3 do {_this addItemToVest "CUP_30Rnd_TE1_Red_Tracer_556x45_G36";}; for "_i" from 1 to 14 do {_this addItemToVest "CUP_1Rnd_HEDP_M203";}; for "_i" from 1 to 10 do {_this addItemToVest "CUP_1Rnd_Smoke_M203";}; for "_i" from 1 to 2 do {_this addItemToVest "CUP_1Rnd_SmokeRed_M203";}; for "_i" from 1 to 2 do {_this addItemToVest "CUP_1Rnd_SmokeGreen_M203";}; _this addWeapon "CUP_arifle_M16A4_GL"; _this additemToUniform "tf_microdagr"; }; fnc_giveWM249 = { _this addItemToVest "CUP_100Rnd_TE4_Red_Tracer_556x45_M249"; _this addWeapon "CUP_lmg_M249"; _this additemtoVest "CUP_optic_ElcanM145"; _this addItemToVest "CUP_100Rnd_TE4_Red_Tracer_556x45_M249"; _this addItemToVest "CUP_100Rnd_TE4_Yellow_Tracer_556x45_M249"; _this addItemToVest "CUP_200Rnd_TE4_Red_Tracer_556x45_M249"; _this additemToVest "CUP_200Rnd_TE4_Yellow_Tracer_556x45_M249"; }; fnc_giveCCO = { _this addPrimaryWeaponItem "FHQ_optic_MicroCCO_tan"; _this addPrimaryWeaponItem "rhsusf_acc_anpeq15_light"; }; fnc_giveACOG = { _this addPrimaryWeaponItem "rhsusf_acc_anpeq15_light"; _this addPrimaryWeaponItem "CUP_optic_ACOG"; }; fnc_givegrensVA = { for "_i" from 1 to 2 do {_this addItemToVest "rhs_mag_mk84";}; for "_i" from 1 to 2 do {_this addItemToVest "rhs_mag_an_m8hc";}; for "_i" from 1 to 2 do {_this addItemToVest "rhs_mag_m18_green";}; for "_i" from 1 to 2 do {_this addItemToVest "rhs_mag_m67";}; }; fnc_giveAARkit = { _this addItemToBackpack "AGM_SpareBarrel"; for "_i" from 1 to 2 do {_this additemtoBackPack "CUP_200Rnd_TE4_Red_Tracer_556x45_M249";}; }; fnc_give556V = { _this addItemToVest "CUP_200Rnd_TE4_Red_Tracer_556x45_M249"; }; // special equipment // special equipment // special equipment fnc_giveMineRSF = { _this additemToBackpack "APERSTripMine_Wire_Mag"; for "_i" from 1 to 2 do {_this additemtoBackPack "rhs_mine_pmn2_mag";}; }; fnc_giveMine = { private ["_Mn"]; _Mn = switch (_this select 1) do { case 1:{"rhs_mine_tm62m_mag"}; // Russian Anti tank blast mine case 2:{"rhs_mine_pmn2_mag"}; // Anti Personal stake mine case 3:{"CUP_PipeBomb_M"}; // remote controlled satchel case 4:{"DemoCharge_Remote_Mag"}; // m112 explosive case 5:{"APERSTripMine_Wire_Mag"}; // Anti personnel bounding mine default {""}; }; if (_Mn == "") exitWith {false}; (_this select 0) additemToBackpack _Mn; true; }; //Benchmark fnc_chgsleep1 = { sleep 0.0000001; }; //sleep 0.0000001 sieht gut aus x 12 = 0.0000012 // 0.1 32 nackte jede zeile eine funktion in jedem loadout // 0.01 26 nackte // 0.001 30 nackte // 0.0001 0 NACKTE // 0.00001; 1-4 nackte // 0.000001 3 nackte // 0.0000001 3 nackte // 0.00000001 0-1 nackter // 0.000000001 4 nackte // 0.0000000001 3 nackte // 0.00000000001 3 nackte // 0.000000000001 2 nackte // 0.0000000000001 2 nackte // 0 1 nackter fnc_chgsleep2 = { sleep 0.0000001; }; and my player loadout that is started through the init field of the unit in the editor : nul=[this] execVM "scripts\loadouts\R.sqf"; // Rifleman Scout private ["_MRP"]; _MRP = _this select 0; IF(!local _MRP) exitwith {}; waitUntil { !isNull player }; _MRP spawn fnc_removeall; [_MRP,1] spawn fnc_giveHelmet; [_MRP,2] spawn fnc_giveUniform; [_MRP,3] spawn fnc_giveVest; [_MRP,2] spawn fnc_giveHeadGToUniform; _MRP spawn fnc_giveCmps; _MRP spawn fnc_giveMS; _MRP spawn fnc_giveitems; _MRP spawn fnc_giveWM16_1; _MRP spawn fnc_giveACOG; _MRP spawn fnc_givegrensVA; _MRP spawn fnc_give556V; //0.003711 ms //0.003809 ms // Line 13,20,24 je 0.001 = 0.003 // Line 14 with 0.0001 after vest seems pretty good = 0.00380859 ms is it the init field? or the compile command? init.sqf: call compile preprocessFile "scripts\functions\functions.sqf"; [] execVM "scripts\RSFspawn.sqf"; TF_give_microdagr_to_soldier = false; I think I am calling the loadouts too early ( obect initalisation field ), before the functions are even compiled through the init.sqf... correct? EDIT: this is not the current state, see last post Edited March 14, 2015 by kOepi Share this post Link to post Share on other sites
demonized 20 Posted March 13, 2015 I got it all running and put out every sleep command.unfortunately in the editor and on dedicated, like 50 % of the units are not completely executed/equipped. try using call instead of spawn, what you do now is start a script removing all, then when "started"(NOTE!! it may not yet be completed) start several different scripts equipping. do it in order, call will complete one, then go to next line. _RSF call fnc_removeall; // clothing [_RSF,1] call fnc_giveHeadGear; [_RSF,3] call fnc_giveFaceW; etc.... the only thing you need to change in your functions is add a true without the ; also why have 180 functions, when you can create one removeFunction and one addStuff function, and rather have seperate equipment lists based on type or whatever you seperate units by. it would streamline your work much more and make it a lot easier for you. Example buildup: 1 removeallstuff fnc. 1 addallstuff fnc 1 script called from init.sqf as you have. then in that script find out what type player is and seperate types by switch, and pass a array with info to the add fnc. [[weapon,mags], hat, west, [inventory items], etc.....] then in the add fnc weapon would be [_this sellect 0; wich would return a array where select 0 is the weapon and select 1 is the ammo count. you can add and change and seperate as much you want.... Just a thought. Share this post Link to post Share on other sites
kOepi 10 Posted March 14, 2015 (edited) @ Demonized was trying to get that call function running. unfortunately I failed. Maybe it was because I cannot call a spawn function. Well I cannot call a call function either. To make it a little simpler I focused on one function just for testing purposes, but without the ";" behind "true", I dont even get a response: my unit is called A0_1 and is adressed correctly. my functions.sqf // marines / (spetsnaz) loadout function fnc_removeall = { removeAllWeapons _this; removeAllItems _this; removeAllAssignedItems _this; removeUniform _this; removeVest _this; removeBackpack _this; removeHeadgear _this; removeGoggles _this; }; fnc_removeall2 = { removeAllWeapons _this; removeAllItems _this; removeAllAssignedItems _this; removeUniform _this; removeVest _this; removeBackpack _this; removeHeadgear _this; removeGoggles _this; true }; // 0.0051 ms // Items, Radios etc... my functionsMP.sqf fnc_Callloadout = { call fnc_removeall2; true }; if (alive A0_1) then { nul = [A0_1] call fnc_CallLoadout; //[A0_1] spawn fnc_CallLoadout; // funktioniert //[A0_1] spawn fnc_removeall; //[A_0_1] execVM "scripts\loadouts\PL.sqf"; //funktioniert //A0_1 spawn fnc_removeall; //funktioniert }; besides that I was trying to use a masterfile to define the loadouts, no idea how I can have less functions with same customization. Plus I had issues with variables ( as I have everywhere) when not using functions. this is a switch / do I was trying to do before that, unfortunately I couldnt get the variables and the arguments to get to work. fnc_Callloadout = { private ["_PL"]; _PL = switch (_this select 1) do { case 1: {fnc_removeall}; // Platoon Leader Loadout Profile default {""}; }; if (_PL == "") exitWith {false}; //(_this select 0) spawn _PL; _PL spawn (_this select 0); true; }; if (alive A0_1) then { nul = [A0_1] call fnc_CallLoadout; //[A0_1] spawn fnc_CallLoadout; // funktioniert //[A0_1] spawn fnc_removeall; //[A_0_1] execVM "scripts\loadouts\PL.sqf"; //funktioniert //A0_1 spawn fnc_removeall; //funktioniert }; EDIT: this is not the current state, see last post Edited March 14, 2015 by kOepi Share this post Link to post Share on other sites
fight9 14 Posted March 14, 2015 You've gotten this shit super complicated. There's functions to call functions to spawn functions to call functions... just for a uniform. What happen to just listing all the shit you need in a single file... _unit = _this select 0; if (!local _unit) exitWith {}; removeAllWeapons _unit; removeUniform _unit; removeHeadgear _unit; _unit addUniform "U_B_HeliPilotCoveralls"; _unit addVest "V_BandollierB_rgr"; _unit addBackpack "B_Kitbag_rgr"; _unit addHeadgear "H_Cap_grn"; _unit addWeapon "binocular"; _unit linkItem "ItemMap"; _unit linkItem "ItemWatch"; _unit addWeapon "CUP_smg_bizon"; _unit addPrimaryWeaponItem "CUP_muzzle_Bizon"; _unit addPrimaryWeaponItem "CUP_optic_Kobra"; _unit addMagazine "CUP_64Rnd_9x19_Bizon_M"; _unit addMagazine "CUP_64Rnd_9x19_Bizon_M"; _unit addMagazine "CUP_64Rnd_9x19_Bizon_M"; _unit addMagazine "CUP_64Rnd_9x19_Bizon_M"; _unit addMagazine "CUP_64Rnd_9x19_Bizon_M"; Put all that in a single file and then call it in the init field with 0 = [this] execVM "scriptName.sqf"; It just seems so much easier! Share this post Link to post Share on other sites
kOepi 10 Posted March 14, 2015 @ fight 9 You've gotten this shit super complicated. There's functions to call functions to spawn functions to call functions... just for a uniform. No, it is for testing purposes only. if I can get the uniform running, I will put the rest of the loadout into it. as I accomplished in this post. I had that running before I started this thread, so this is optimization less important for the player loadouts, much more important for the AI loadouts that spawn in the field, unfortunately not with all the assigned gear until that point. ------------------------------------------ I came one step further: now I can call functions without a switch / do. so this is what I am working on right now: fnc_removeall2 = { private ["_allunits"]; _allunits = (_this select 0); removeAllWeapons _allunits; removeAllItems _allunits; removeAllAssignedItems _allunits; removeUniform _allunits; removeVest _allunits; removeBackpack _allunits; removeHeadgear _allunits; removeGoggles _allunits; true; }; // Problem starts: I have to set for each case the global variable, for case 1 it is A0_1, case 2 it is A0_2 ... fnc_Callloadout3 = { call fnc_removeall2; // works private ["_unitname"]; _unitname = switch (_this select 1) do { case 1:{"scripts\loadouts\PL.sqf"}; // Platoon Leader Profile case 2:"scripts\loadouts\PS.sqf"}; // Platoon Sergeant Profile case 3:{"scripts\loadouts\FRO.sqf"}; // Field Radio Operator case 4:{"scripts\loadouts\HM.sqf"}; // Hospital Corpsman default {""}; }; if (_unitname == "") exitWith {false}; (_this select 0) execVM _unitname; true; }; // Problem ends // below the unit is initializes for testing purposes, will be replace through a switch / do executed in the initplayer, combined with a eventhandler "respawn", so the unit respawns with this loadout aswell if (alive A0_1) then { //nul = [A0_1] call fnc_CallLoadout; [A0_1] call fnc_CallLoadout3; // works with fnc callloadout 1 and 2 }; and in my loadoutprofile PL.sqf: // Platoon Leader private ["_MRP"]; _MRP = (_this select 0); IF(!local _MRP) exitwith {}; waitUntil { !isNull player }; [_MRP,8] call fnc_giveHeadGear; [_MRP,5] call fnc_giveUniform; [_MRP,4] call fnc_giveVest; [_MRP,4] call fnc_giveFaceW; [_MRP,4] call fnc_giveHeadGToUniform; _MRP call fnc_giveCmps; _MRP call fnc_giveMS; _MRP call fnc_giveitems; _MRP call fnc_giveWM16_2; _MRP call fnc_givegrensVA; _MRP call fnc_giveWM1911; Share this post Link to post Share on other sites