Raider_18 7 Posted April 26 2 hours ago, pierremgi said: if (_unit IsKindOf "CAManBase") then { call { if (faction _unit isEqualTo "BLU_F") exitwith {[_unit] spawn CB_fnc_loadout_BLUFORnato}; // standard NATO if (faction _unit isEqualTo "BLU_CTRG_F") exitWith {[_unit] spawn CB_fnc_loadout_BLUFORspecops}; // CTRG if (faction _unit isEqualTo "BLU_G_F") exitWith {[_unit] spawn CB_fnc_loadout_BLUFORion}; // FIA as IoN security if (faction _unit isEqualTo "OPF_F") exitWith {[_unit] spawn CB_fnc_loadout_OPFORcsat}; // standard CSAT if (faction _unit isEqualTo "OPF_R_F") exitWith {[_unit] spawn CB_fnc_loadout_OPFORspecops}; // Spetznaz as Viper guys if (faction _unit isEqualTo "IND_G_F") exitWith {[_unit] spawn CB_fnc_loadout_INDFORfia}; // standard FIA if (faction _unit isEqualTo "IND_C_F") exitWith {[_unit] spawn CB_fnc_loadout_INDFORspecops}; // Syndikat as common criminals if (faction _unit isEqualTo "CIV_F") exitWith {[_unit] spawn CB_fnc_loadout_CIV}; }; }; Roger that, changed. Thanks! Share this post Link to post Share on other sites
pierremgi 4853 Posted April 26 btw, you could use a hashmap , probably better for preparing such script(s). Something like: CB_Factions_data = createHashMapFromArray [ ["BLU_F", [ [ "WhiteHead_01", "WhiteHead_05", "WhiteHead_04",...], [ "U_I_L_Uniform_01_tshirt_black_F", .5, "U_I_L_Uniform_01_tshirt_olive_F", .5, "U_I_L_Uniform_01_tshirt_skull_F", .5,....], [ "\a3\characters_f_gamma\Civil\Data\c_cloth1_black.paa", "A3\Characters_F\Civil\Data\c_cloth1_kabeiroi_co.paa", ....], [ "V_LegStrapBag_olive_F", "V_LegStrapBag_coyote_F", "V_LegStrapBag_black_F", "V_Pocketed_black_F", ...], [ "H_Beret_blk", "H_Bandanna_gry", "H_Bandanna_blu", "H_Bandanna_cbr", "H_Booniehat_taiga", "H_Booniehat_wdl",....], [ "arifle_AKM_F", "arifle_AKS_F", "arifle_AK12U_F", "arifle_CTAR_blk_F" ,...], [....] ], ], ["BLU_CTRG_F", [[...],[...],...]] ], .... ]; This way, you can see the whole things you want and the codes are faster. You create the hashmap once for all, then use it multiple times. Usage is a little bit different from testing a condition and running a script. Just: private _factionData = CB_Factions_Data get faction _unit; _unit setFace selectRandom (_factionData #0); _unit forceAddUniform selectRandomWeighted (_factionData #1); if (_factionData == "IND_G_F" && {uniform _unit == "U_IG_Guerilla1_1"} && {random 10 > 5} ) then { _unit setObjectTextureGlobal [0, _fiaFatigues]; _unit setobjectTextureGlobal [1, "#(argb,8,8,3)color(0.33,0.31,0.24,0.3)"] }; _unit addVest selectRandom (_factionData #3); There is no delay whatever the key (faction here) could be. Of course, it's a dirty example. Adapt and mind for the arrays and the global structure of the hashmap. Have fun 1 Share this post Link to post Share on other sites
Larrow 2820 Posted April 26 Why init.sqf ? So this is happening everywhere! Should just be initServer.sqf and then remoteExec the loadout script to where the unit is local, due to some of the commands being LA. //initServer.sqf // detect and change all editor placed units { [_x] call CB_fnc_factionConfig; } forEach ( allUnits select { _x isKindOf "CAManBase" && { !isPlayer _x }} ); // add MEH to catch anything spawned CB_MEH_factions = addMissionEventHandler ["EntityCreated", { params ["_entity"]; if ( _entity isKindOf 'CAManBase' && { !isPlayer _entity }) then {[_entity] call CB_fnc_factionConfig}; }]; //CB_fnc_factionConfig // handles params[ "_unit" ]; //Everything here will already be CAManBase and !player //ignore special units with this variable // factions to re-paint private _scriptName = switch ( faction _unit ) do { case ( "BLU_F" ) : { "BLUFORnato" }; case ( "BLU_CTRG_F" ) : { "BLUFORspecops" }; case ( "BLU_G_F" ) : { "BLUFORion" }; case ( "OPF_F" ) : { "OPFORcsat" }; case ( "OPF_R_F" ) : { "OPFORspecops" }; case ( "IND_G_F" ) : { "INDFORfia" }; case ( "IND_C_F" ) : { "INDFORspecops" }; case ( "CIV_F" ) : { "CIV" }; }; [ _unit ] remoteExec[ format[ "CB_fnc_loadout_%1", _scriptName ], _unit ]; 1 Share this post Link to post Share on other sites
Raider_18 7 Posted April 26 _bigThanks = "Many thanks, you guys are awesome!! 😁"; _homies = getPos (Pierremgi && @Larrow); _message = _bigThanks deliverTo _homies; Will reconfigure and I am learning alot by your examples. Thanks to you both. Will try to post an example mission with it cleaned up soon, so others can take an inside look. Share this post Link to post Share on other sites
Raider_18 7 Posted May 23 Spoiler On 4/26/2024 at 3:34 AM, pierremgi said: btw, you could use a hashmap , probably better for preparing such script(s). Something like: CB_Factions_data = createHashMapFromArray [ ["BLU_F", [ [ "WhiteHead_01", "WhiteHead_05", "WhiteHead_04",...], [ "U_I_L_Uniform_01_tshirt_black_F", .5, "U_I_L_Uniform_01_tshirt_olive_F", .5, "U_I_L_Uniform_01_tshirt_skull_F", .5,....], [ "\a3\characters_f_gamma\Civil\Data\c_cloth1_black.paa", "A3\Characters_F\Civil\Data\c_cloth1_kabeiroi_co.paa", ....], [ "V_LegStrapBag_olive_F", "V_LegStrapBag_coyote_F", "V_LegStrapBag_black_F", "V_Pocketed_black_F", ...], [ "H_Beret_blk", "H_Bandanna_gry", "H_Bandanna_blu", "H_Bandanna_cbr", "H_Booniehat_taiga", "H_Booniehat_wdl",....], [ "arifle_AKM_F", "arifle_AKS_F", "arifle_AK12U_F", "arifle_CTAR_blk_F" ,...], [....] ], ], ["BLU_CTRG_F", [[...],[...],...]] ], .... ]; @pierre MGI Been messing around with the hashmap stuff, as I agree after reading up it seems like the way to go. I use the following code in the debug console to interact with the hashmap and try to learn how it works. I hope it might help someone experimenting with it. I can get what I want from the key/value relationship now which is, a random element from the nested array. in debug console Spoiler testhash = ["face","vest","weapon"] createHashMapFromArray [ ["face1", "face2", "face3"], ["vest1", "vest2", "vest3"], ["rifle1", "rifle2", "rifle3"] ]; testhash toArray true; private _data = selectRandom (testhash get "face"); hint str _data; //_data = selectRandom (testhash get "vest"); hint str _data; //_data = selectRandom (testhash get "weapon"); hint str _data; what it might end up like in my loadout function is giving each faction a hashmap in a seperate .hpp file, and then just use the KEYS as the categories and the VALUES as possible choices like in the example above, just because so far it works and im not nearly clever enough to even understand what's really happening here. Speaking of which, notice the toArray command. I have no clue why but it needs to be there. Found that information here: I can only read it for about 5 minutes before my brain starts hurting but, she works and that's all that matters. Some more helpful links for the folks. https://community.bistudio.com/wiki/HashMap#HashMap_Basics https://community.bistudio.com/wiki/Category:Command_Group:_HashMap Share this post Link to post Share on other sites
pierremgi 4853 Posted May 25 On 5/23/2024 at 10:59 PM, Raider_18 said: @pierre MGI Been messing around with the hashmap stuff, as I agree after reading up it seems like the way to go. I use the following code in the debug console to interact with the hashmap and try to learn how it works. I hope it might help someone experimenting with it. I can get what I want from the key/value relationship now which is, a random element from the nested array. Found that information here: I can only read it for about 5 minutes before my brain starts hurting but, she works and that's all that matters. At this time, don't create a hashmap with (empty) hashmap (here map of m). Hashmap of arrays is fine. 1 Share this post Link to post Share on other sites