darkxess 60 Posted February 10, 2020 Hi, I have this working but I want it to work in a better way, maybe via script and server-wide for MP? call{(group this) setGroupId ["Command"]; removeAllWeapons this; this; call{null = [this] execVM "Loadouts\Altis\Squadleader.sqf"; this addeventhandler ["respawn","_this execVM 'Loadouts\Altis\Squadleader.sqf'"];}} ^That is how I have it now, loading just a simple loadout script I have for each role (squadleader, medic, rifleman) etc... sometimes though the uniform doesn't load after dying so you need to die again and strangely that fixes it lol. Is there a way I can just have the uniform and loadout working by script so when a player joins ie a (Rifleman) role he will have the uniform and loadout which is what we want to load. Of course all working by MP and upon death the same loadout etc. Thanks 🙂 Share this post Link to post Share on other sites
stanhope 411 Posted February 10, 2020 In initplayerlocal do a switch over typeof player and in the cases apply the loadout you want. At the end of initplayerlocal, after that switch case put something along these lines: player setVariable ['PlayerLoadout', (getUnitLoadout player)]; And then in onplayerrespawn put something alone the lines of: if (!isNil {player getVariable "PlayerLoadout"}) then { player setUnitLoadout [player getVariable "PlayerLoadout", true]; }; 2 Share this post Link to post Share on other sites
darkxess 60 Posted February 10, 2020 @stanhope you mean the (initPlayerLocal.sqf) not the init of the playable unit? if it was for MP wouldn't I have to add it to (initServer.sqf) too? just wondering. I kind of get what you put but I'm confused too, the (PlayerLoadout) is where my script would be located or? the Loadouts I have made will still exist this way or? Sorry, I'm not a perfect scripter so I may sound stupid lol. Share this post Link to post Share on other sites
stanhope 411 Posted February 10, 2020 No so, a player's loadout is local to the player, the server doesn't have anything to do with it (huge oversimplification but good enough for this) So in a file called initPlayerLocal.sqf you add something like this (the following might be full of syntax errors, I didn't test any of it, just writing it from memory): switch (typeOf player) do { case "B_Soldier_F": { [player] execVM "YourScriptForTheLoadoutGoesHere"; break; }; default { hint "Something went wrong while applying your loadout, could not identify your role: " + typeOf player; }; }; player setVariable ['PlayerLoadout', (getUnitLoadout player)]; And then in onPlayerRespawn.sqf you add if (!isNil {player getVariable "PlayerLoadout"}) then { player setUnitLoadout [player getVariable "PlayerLoadout", true]; }; The switch and everything in it is what you use to set up the loadout initially, then you use the setvar and getvar to reapply this loadout upon respawn. 1 Share this post Link to post Share on other sites
darkxess 60 Posted February 11, 2020 @stanhope is it very possible you could create me an example mission, please? I tried the above and still can't get it to work 😐 Share this post Link to post Share on other sites
stanhope 411 Posted February 11, 2020 Here's an example from a mission I work on: Spoiler In initplayerlocal.sqf: private _loadoutScript = [] execVM "Scripts\arsenal\unitLoadout.sqf"; //Default loadout [_loadoutScript] spawn { params ["_loadoutScript"]; waitUntil {sleep 0.1; scriptDone _loadoutScript}; player setVariable ['PlayerLoadout', (getUnitLoadout player)]; }; In unitLoadout.sqf: private _unitType = typeOf player; { player removeWeapon _x; } forEach (weapons player); removeHeadgear player; removeVest player; removeBackpack player; removeUniform player; private _radioItem = "ItemRadio"; if (isClass (configFile >> "CfgPatches" >> "task_force_radio")) then { _radioItem = "TFAR_anprc152"; }; switch (_unitType) do { case "B_recon_TL_F"; case "B_recon_JTAC_F"; case "B_Soldier_SL_F": {player setUnitLoadout [["arifle_MX_GL_Black_F","","acc_pointer_IR","optic_Hamr",["30Rnd_65x39_caseless_black_mag",30],[],""],[],[],["U_B_CombatUniform_mcam",[["FirstAidKit",2],["SmokeShellBlue",2,1],["HandGrenade",1,1],["Laserbatteries",1,1]]],["V_PlateCarrier2_rgr",[["30Rnd_65x39_caseless_black_mag",4,30],["30Rnd_65x39_caseless_black_mag_Tracer",1,30],["1Rnd_HE_Grenade_shell",3,1],["1Rnd_SmokeBlue_Grenade_shell",3,1],["1Rnd_SmokeOrange_Grenade_shell",2,1],["1Rnd_SmokePurple_Grenade_shell",2,1],["1Rnd_SmokeYellow_Grenade_shell",2,1],["1Rnd_SmokeGreen_Grenade_shell",2,1],["1Rnd_Smoke_Grenade_shell",2,1]]],[],"H_HelmetB","",["Laserdesignator","","","",["Laserbatteries",1],[],""],["ItemMap","ItemGPS",_radioItem,"ItemCompass","ItemWatch","NVGoggles"]]}; case "B_recon_medic_F"; case "B_medic_F": {player setUnitLoadout [["arifle_MX_Black_F","","","optic_Hamr",["30Rnd_65x39_caseless_black_mag",30],[],""],[],[],["U_B_CombatUniform_mcam",[["FirstAidKit",2],["SmokeShellBlue",2,1],["HandGrenade",1,1]]],["V_PlateCarrier2_rgr",[["30Rnd_65x39_caseless_black_mag",4,30],["30Rnd_65x39_caseless_black_mag_Tracer",1,30],["SmokeShellBlue",2,1]]],["B_TacticalPack_rgr",[["Medikit",1],["FirstAidKit",20]]],"H_HelmetSpecB","",[],["ItemMap","ItemGPS",_radioItem,"ItemCompass","ItemWatch","NVGoggles"]]}; case "B_soldier_repair_F": {player setUnitLoadout [["arifle_MX_Black_F","","","optic_Hamr",["30Rnd_65x39_caseless_black_mag",30],[],""],[],[],["U_B_CombatUniform_mcam",[["FirstAidKit",2],["HandGrenade",1,1],["SmokeShellBlue",2,1]]],["V_PlateCarrier2_rgr",[["30Rnd_65x39_caseless_black_mag",4,30],["30Rnd_65x39_caseless_black_mag_Tracer",1,30]]],["B_AssaultPack_rgr",[["ToolKit",1]]],"H_HelmetB","",[],["ItemMap","",_radioItem,"ItemCompass","ItemWatch","NVGoggles"]]}; case "B_soldier_AR_F": {player setUnitLoadout [["LMG_Mk200_F","","","optic_Hamr",["200Rnd_65x39_cased_Box",200],[],"bipod_01_F_blk"],[],[],["U_B_CombatUniform_mcam",[["FirstAidKit",2],["HandGrenade",1,1],["SmokeShellBlue",2,1]]],["V_PlateCarrier2_rgr",[["200Rnd_65x39_cased_Box",2,200]]],["B_AssaultPack_rgr",[["200Rnd_65x39_cased_Box",2,200]]],"H_HelmetB","",["Binocular","","","",[],[],""],["ItemMap","",_radioItem,"ItemCompass","ItemWatch","NVGoggles"]] }; case "B_Soldier_GL_F": {player setUnitLoadout [["arifle_MX_GL_Black_F","","acc_pointer_IR","optic_Hamr",["30Rnd_65x39_caseless_black_mag",30],[],""],[],[],["U_B_CombatUniform_mcam",[["FirstAidKit",2],["SmokeShellBlue",2,1],["HandGrenade",1,1],["Laserbatteries",1,1]]],["V_PlateCarrier2_rgr",[["30Rnd_65x39_caseless_black_mag",4,30],["30Rnd_65x39_caseless_black_mag_Tracer",1,30],["1Rnd_HE_Grenade_shell",3,1],["1Rnd_SmokeBlue_Grenade_shell",3,1],["1Rnd_SmokeOrange_Grenade_shell",2,1],["1Rnd_SmokePurple_Grenade_shell",2,1],["1Rnd_SmokeYellow_Grenade_shell",2,1],["1Rnd_SmokeGreen_Grenade_shell",2,1],["1Rnd_Smoke_Grenade_shell",2,1]]],[],"H_HelmetB","",["Laserdesignator","","","",["Laserbatteries",1],[],""],["ItemMap","ItemGPS",_radioItem,"ItemCompass","ItemWatch","NVGoggles"]]}; case "B_recon_M_F"; case "B_soldier_M_F": {player setUnitLoadout [["srifle_EBR_F","","acc_pointer_IR","optic_DMS",[],[],"bipod_01_F_blk"],[],[],["U_B_CombatUniform_mcam",[["FirstAidKit",2],["HandGrenade",1,1],["SmokeShellBlue",2,1],["Laserbatteries",1,1]]],["V_PlateCarrier2_rgr",[["20Rnd_762x51_Mag",6,20]]],[],"H_HelmetB_camo","G_Bandanna_tan",["Laserdesignator","","","",["Laserbatteries",1],[],""],["ItemMap","",_radioItem,"ItemCompass","ItemWatch","NVGoggles"]] }; case "B_recon_LAT_F"; case "B_soldier_AT_F": {player setUnitLoadout [["arifle_MXC_Black_F","","","optic_Hamr",["30Rnd_65x39_caseless_black_mag",30],[],""],["launch_B_Titan_short_F","","","",["Titan_AT",1],[],""],[],["U_B_CombatUniform_mcam",[["FirstAidKit",2],["HandGrenade",1,1],["SmokeShellBlue",2,1]]],["V_PlateCarrier1_rgr",[["30Rnd_65x39_caseless_black_mag",5,30]]],["B_Kitbag_rgr",[["Titan_AT",2,1],["Titan_AP",1,1]]],"H_HelmetB","",[],["ItemMap","",_radioItem,"ItemCompass","ItemWatch","NVGoggles"]] }; case "B_soldier_LAT_F": {player setUnitLoadout [["arifle_MX_Black_F","","","optic_Hamr",["30Rnd_65x39_caseless_black_mag",30],[],""],["launch_RPG32_F","","","",["RPG32_F",1],[],""],[],["U_B_CombatUniform_mcam",[["FirstAidKit",2],["SmokeShellBlue",2,1],["HandGrenade",1,1]]],["V_PlateCarrier2_rgr",[["30Rnd_65x39_caseless_black_mag",5,30]]],["B_AssaultPack_rgr",[["RPG32_F",2,1],["RPG32_HE_F",1,1]]],"H_HelmetB","",[],["ItemMap","",_radioItem,"ItemCompass","ItemWatch","NVGoggles"]] }; case "B_Soldier_TL_F": {player setUnitLoadout [["arifle_MX_GL_Black_F","","acc_pointer_IR","optic_Hamr",["30Rnd_65x39_caseless_black_mag",30],[],""],["launch_RPG32_F","","","",["RPG32_F",1],[],""],[],["U_B_CombatUniform_mcam",[["FirstAidKit",2],["SmokeShellBlue",2,1],["HandGrenade",1,1],["Laserbatteries",1,1]]],["V_PlateCarrier2_rgr",[["DemoCharge_Remote_Mag",2,1],["30Rnd_65x39_caseless_black_mag",5,30],["1Rnd_HE_Grenade_shell",3,1],["1Rnd_Smoke_Grenade_shell",2,1],["1Rnd_SmokeGreen_Grenade_shell",2,1],["1Rnd_SmokeBlue_Grenade_shell",2,1]]],[],"H_HelmetB","",["Laserdesignator","","","",["Laserbatteries",1],[],""],["ItemMap","ItemGPS",_radioItem,"ItemCompass","ItemWatch","NVGoggles"]] }; case "B_engineer_F": {player setUnitLoadout [["arifle_MX_Black_F","","","optic_Hamr",["30Rnd_65x39_caseless_black_mag",30],[],""],[],[],["U_B_CombatUniform_mcam",[["FirstAidKit",2],["HandGrenade",1,1],["SmokeShellBlue",2,1]]],["V_PlateCarrier2_rgr",[["MineDetector",1],["30Rnd_65x39_caseless_black_mag",5,30],["ClaymoreDirectionalMine_Remote_Mag",3,1]]],["B_AssaultPack_rgr",[["ToolKit",1],["DemoCharge_Remote_Mag",4,1]]],"H_HelmetB","",[],["ItemMap","ItemGPS",_radioItem,"ItemCompass","ItemWatch","NVGoggles"]] }; case "B_recon_exp_F"; case "B_soldier_exp_F": {player setUnitLoadout [["arifle_MX_Black_F","","","optic_MRCO",["30Rnd_65x39_caseless_black_mag",30],[],""],[],[],["U_B_CombatUniform_mcam",[["FirstAidKit",2],["HandGrenade",1,1],["SmokeShellBlue",2,1]]],["V_PlateCarrier1_rgr",[["MineDetector",1],["30Rnd_65x39_caseless_black_mag",5,30]]],["B_Kitbag_rgr",[["ToolKit",1],["DemoCharge_Remote_Mag",4,1],["ClaymoreDirectionalMine_Remote_Mag",2,1],["APERSTripMine_Wire_Mag",2,1],["APERSBoundingMine_Range_Mag",2,1]]],"H_HelmetB","",[],["ItemMap","",_radioItem,"ItemCompass","ItemWatch","NVGoggles"]] }; case "B_sniper_F": {player setUnitLoadout [["srifle_LRR_F","","","optic_LRPS",["7Rnd_408_Mag",7],[],""],[],[],["U_B_CombatUniform_mcam_tshirt",[["FirstAidKit",2],["SmokeShellBlue",2,1],["HandGrenade",1,1]]],["V_PlateCarrier1_rgr",[["7Rnd_408_Mag",8,7]]],[],"H_Booniehat_mcamo","",[],["ItemMap","ItemGPS",_radioItem,"ItemCompass","ItemWatch","NVGoggles"]] }; case "B_spotter_F": {player setUnitLoadout [["arifle_MX_Black_F","","","optic_Hamr",[],[],""],[],[],["U_B_CombatUniform_mcam",[["FirstAidKit",2],["SmokeShellBlue",2,1],["HandGrenade",1,1],["Laserbatteries",1,1]]],["V_PlateCarrier2_rgr",[["30Rnd_65x39_caseless_black_mag",4,30],["30Rnd_65x39_caseless_black_mag_Tracer",1,30]]],[],"H_Booniehat_mcamo","",["Laserdesignator","","","",["Laserbatteries",1],[],""],["ItemMap","ItemGPS",_radioItem,"ItemCompass","ItemWatch","NVGoggles"]] }; case "B_support_Mort_F": {player setUnitLoadout [["arifle_MXC_Black_F","","","optic_Hamr",["30Rnd_65x39_caseless_black_mag",30],[],""],[],[],["U_B_CombatUniform_mcam",[["FirstAidKit",2],["SmokeShellBlue",2,1],["HandGrenade",1,1],["Laserbatteries",1,1]]],["V_PlateCarrier1_rgr",[["30Rnd_65x39_caseless_black_mag",4,30],["30Rnd_65x39_caseless_black_mag_Tracer",1,30]]],["B_Mortar_01_weapon_F",[]],"H_Booniehat_mcamo","",["Laserdesignator","","","",["Laserbatteries",1],[],""],["ItemMap","ItemGPS",_radioItem,"ItemCompass","ItemWatch","NVGoggles"]] }; case "B_soldier_UAV_F": {player setUnitLoadout [["arifle_MXC_Black_F","","","optic_Hamr",["30Rnd_65x39_caseless_black_mag",30],[],""],[],[],["U_B_CombatUniform_mcam_tshirt",[["FirstAidKit",2],["Laserbatteries",1,1],["SmokeShellBlue",2,1],["HandGrenade",1,1]]],["V_Chestrig_rgr",[["30Rnd_65x39_caseless_black_mag",4,30],["30Rnd_65x39_caseless_black_mag_Tracer",1,30]]],["B_UAV_01_backpack_F",[]],"H_Booniehat_mcamo","",["Laserdesignator","","","",["Laserbatteries",1],[],""],["ItemMap","B_UavTerminal",_radioItem,"ItemCompass","ItemWatch","NVGoggles"]] }; case "B_Helipilot_F": {player setUnitLoadout [["SMG_03C_black","","","",["50Rnd_570x28_SMG_03",50],[],""],[],[],["U_B_HeliPilotCoveralls",[["FirstAidKit",2],["SmokeShellBlue",2,1],["HandGrenade",1,1],["Laserbatteries",1,1]]],["V_TacVest_blk",[["50Rnd_570x28_SMG_03",2,50],["SmokeShellBlue",2,1]]],[],"H_CrewHelmetHeli_B","G_Bandanna_beast",["Laserdesignator","","","",["Laserbatteries",1],[],""],["ItemMap","ItemGPS",_radioItem,"ItemCompass","ItemWatch","NVGoggles_OPFOR"]] }; }; And in onplayerrespawn: if (!isNil {player getVariable "PlayerLoadout"}) then { player setUnitLoadout [player getVariable "PlayerLoadout", true]; }; My usage of switch case in my previous comment was incorrect, that's what you get from writing from memory 🙂 1 Share this post Link to post Share on other sites
darkxess 60 Posted February 11, 2020 @stanhope thank you very much mate, works perfectly and I can see now how its done exactlyJust one question, how would I be able to do this on unit loadout export easily instead of a wall of text as it does lol. Is there some kind of program to do such or? {player setUnitLoadout [["arifle_MX_GL_Black_F","","acc_pointer_IR","optic_Hamr",["30Rnd_65x39_caseless_black_mag",30],[],""],[],[],["U_B_CombatUniform_mcam",[["FirstAidKit",2],["SmokeShellBlue",2,1],["HandGrenade",1,1],["Laserbatteries",1,1]]],["V_PlateCarrier2_rgr",[["30Rnd_65x39_caseless_black_mag",4,30],["30Rnd_65x39_caseless_black_mag_Tracer",1,30],["1Rnd_HE_Grenade_shell",3,1],["1Rnd_SmokeBlue_Grenade_shell",3,1],["1Rnd_SmokeOrange_Grenade_shell",2,1],["1Rnd_SmokePurple_Grenade_shell",2,1],["1Rnd_SmokeYellow_Grenade_shell",2,1],["1Rnd_SmokeGreen_Grenade_shell",2,1],["1Rnd_Smoke_Grenade_shell",2,1]]],[],"H_HelmetB","",["Laserdesignator","","","",["Laserbatteries",1],[],""],["ItemMap","ItemGPS",_radioItem,"ItemCompass","ItemWatch","NVGoggles"]]}; by a wall of text I mean by something like this (imgur link) so from that to a line as you have done it, which way is best? Share this post Link to post Share on other sites
stanhope 411 Posted February 11, 2020 Load the load-out you want and run "copyToClipboard str (getUnitLoadout player)". (This line only works in SP and on locally hosted servers due to limitations of copyToClipboard) 1 Share this post Link to post Share on other sites
darkxess 60 Posted February 11, 2020 1 hour ago, stanhope said: Load the load-out you want and run "copyToClipboard str (getUnitLoadout player)". (This line only works in SP and on locally hosted servers due to limitations of copyToClipboard) Thank you, wondered how to do this at first but just found a guide, all done 🙂 Share this post Link to post Share on other sites