Jump to content
Sign in to follow this  
loopdk

Custom loadouts sgf file style

Recommended Posts

Hello boys ...

I have previously used VAS but now I think it is full of errors .. it is due to updates in core files or what I do not know but I am looking for a new way to load custom loadouts on.

I have a pile SQF files ...

NCO

Medic

DMR

etc.

I have tried me to load them in via the init line in each figure, that also works very well right until a new player joins ore dies and respawn

So disappears everyone's equipment and magasins , so unfortunately its not working..

http://forums.bistudio.com/showthread.php?150985-Respawn-with-Custom-loadout

Is it possible to make an ammo box or a flagpole or similar where I like the old VAS box can go and get the action "NCO" MEDIC "and so forth and so it loads the real sgf file ??

I am not interested in having access to the rest of the box ... it is very important that only those from sgf files.

Some suggestions ???

loop

3PARA-GU

Share this post


Link to post
Share on other sites

Hey dude, can you make an example of custom setups by using this initPlayerLocal.sqf method ?

Share this post


Link to post
Share on other sites

Pretty simple, create a file named initPlayerLocal with file extension .sqf, then within that execute your loadout script, you may have to wait for the player to "exist" before executing, those lines of code I will include below:

waitUntil {!isNull player};
waitUntil {time > 0};

_nul = [player] execVM "loadout.sqf";

Share this post


Link to post
Share on other sites
Pretty simple, create a file named initPlayerLocal with file extension .sqf, then within that execute your loadout script, you may have to wait for the player to "exist" before executing, those lines of code I will include below:

waitUntil {!isNull player};
waitUntil {time > 0};

_nul = [player] execVM "loadout.sqf";

ok, so, I put initPlayerLocal.sqf in my mission folder (is it auto launched when mission start / players join ? )

inside initPlayerLocal.sqf I put these

waitUntil {!isNull player};
waitUntil {time > 0};

_nul = [s1] execVM "loadout1.sqf";

_nul = [s2] execVM "loadout2.sqf";

inside "loadout.sqf" something like :


_unit = _this select 0;

removeallweapons _unit; 
removevest _unit; 
removeuniform _unit; 
removeheadgear _unit;
removeallassigneditems _unit;

sleep 1;

[[{}, _unit addUniform "U_mas_uk_B_IndUniform2_o"], "BIS_fnc_spawn", true] call BIS_fnc_MP; //attention to the syntax here. This, and only this syntax worked for me, even with other resources showing differently

_unit addHeadgear 'H_mas_uk_beret'; 
 _unit addGoggles 'G_Aviator'; 
 _unit addVest 'V_mas_uk_Rangemaster_belt'; 
 _unit addBackPack 'B_AssaultPack_cbr'; 
 _unit addmagazine '13Rnd_mas_9x21_Mag'; 
 _unit addweapon 'hgun_mas_bhp_F'; 
 _unit addmagazine 'CUP_30Rnd_556x45_Stanag'; 
 _unit addweapon 'CUP_arifle_Mk16_CQC_SFG'; 
 _unit addweapon 'CUP_LRTV'; 
 _unit addPrimaryWeaponItem 'CUP_muzzle_snds_SCAR_L'; 
 _unit addPrimaryWeaponItem 'CUP_acc_ANPEQ_15'; 
 _unit addPrimaryWeaponItem 'CUP_optic_ELCAN_SpecterDR'; 
 _unit addHandgunItem 'muzzle_mas_snds_L'; 
 _unit addItemToUniform 'FirstAidKit'; 
 _unit addItemToUniform 'FirstAidKit'; 
 _unit addItemToUniform '13Rnd_mas_9x21_Mag'; 
 _unit addItemToUniform '13Rnd_mas_9x21_Mag'; 
 _unit addItemToUniform 'B_IR_Grenade'; 
 _unit addItemToUniform 'SmokeShell'; 
 _unit addItemToUniform 'SmokeShell'; 
 _unit addItemToUniform 'SmokeShell'; 
 _unit addItemToUniform 'HandGrenade'; 
 _unit addItemToVest 'CUP_30Rnd_556x45_Stanag'; 
 _unit addItemToVest 'CUP_30Rnd_556x45_Stanag'; 
 _unit addItemToVest 'CUP_30Rnd_556x45_Stanag'; 
 _unit addItemToVest 'CUP_30Rnd_556x45_Stanag'; 
 _unit addItemToVest 'CUP_30Rnd_556x45_Stanag'; 
 _unit addItemToVest 'CUP_30Rnd_556x45_Stanag'; 
 _unit addItemToVest 'CUP_30Rnd_556x45_Stanag'; 
 _unit addItemToVest 'CUP_30Rnd_556x45_Stanag'; 
 _unit addItemToVest '13Rnd_mas_9x21_Mag'; 
 _unit addItemToVest '13Rnd_mas_9x21_Mag'; 
 _unit addItemToVest '13Rnd_mas_9x21_Mag'; 
 _unit addItemToVest '13Rnd_mas_9x21_Mag'; 
 _unit addItemToVest 'SmokeShell'; 
 _unit addItemToVest 'SmokeShell'; 
 _unit addItemToBackpack 'HandGrenade'; 
 _unit addItemToBackpack 'HandGrenade'; 
 _unit addItemToBackpack 'HandGrenade'; 
 _unit addItemToBackpack 'SmokeShellRed'; 
 _unit addItemToBackpack 'SmokeShellRed'; 
 _unit addItemToBackpack 'SmokeShellGreen'; 
 _unit addItemToBackpack 'SmokeShellGreen'; 
 _unit addItemToBackpack 'SmokeShellPurple'; 
 _unit addItemToBackpack 'SmokeShellPurple'; 
 _unit addItemToBackpack 'Chemlight_green'; 
 _unit addItemToBackpack 'Chemlight_red'; 
 _unit addItemToBackpack 'CUP_30Rnd_556x45_Stanag'; 
 _unit addItemToBackpack 'CUP_30Rnd_556x45_Stanag'; 
 _unit addItemToBackpack 'CUP_30Rnd_556x45_Stanag'; 
 _unit addItemToBackpack 'CUP_30Rnd_556x45_Stanag'; 
 _unit linkItem 'ItemMap'; 
 _unit linkItem 'ItemCompass'; 
 _unit linkItem 'ItemWatch'; 
 _unit linkItem 'ItemRadio'; 
 _unit linkItem 'ItemGPS'; 
 _unit linkItem 'NVGoggles_mas_h'; 
 _unit linkItem 'CUP_LRTV'; 

should it work fine ?

I'am really searching for something that I can use to give custom loadouts to playable and non playable units and that never broke when human players join

thanks for helping

Share this post


Link to post
Share on other sites

Correct, it runs once on missions start for all players at the time, and then for each client (locally) that JIPs (joins in progress).

Share this post


Link to post
Share on other sites
Correct, it runs once on missions start for all players at the time, and then for each client (locally) that JIPs (joins in progress).

awesome, I'll try it out, thanks

Share this post


Link to post
Share on other sites

I tried your method and look like it works fine for human controlled players but when other players join in MP then some of the AI controlled soldiers lose their uniform : (

Share this post


Link to post
Share on other sites

Ok, in that case we need to use get/set variable, so at the end of the loadout scripts put this:

_unit setVariable ["hasLoadout", true, true];

And at the top (under the definition of "_unit") put this:

_unit = (_this select 0);
if (_unit getVariable ["hasLoadout",false]) exitWith {};

//...rest of code

Share this post


Link to post
Share on other sites

ok, let's see if I got it, I know very little of scripting, the initPlayerLocal.sqf should now look like below, right ?

waitUntil {!isNull player};
waitUntil {time > 0};

_nul = [s1] execVM "loadout1.sqf";

_nul = [s2] execVM "loadout2.sqf";

_unit setVariable ["hasLoadout", true, true];

While inside each "loadoutX.sqf" this ?:


_unit = (_this select 0);
if (_unit getVariable ["hasLoadout",false]) exitWith {};


removeallweapons _unit; 
removevest _unit; 
removeuniform _unit; 
removeheadgear _unit;
removeallassigneditems _unit;

sleep 1;

[[{}, _unit addUniform "U_mas_uk_B_IndUniform2_o"], "BIS_fnc_spawn", true] call BIS_fnc_MP; //attention to the syntax here. This, and only this syntax worked for me, even with other resources showing differently

_unit addHeadgear 'H_mas_uk_beret'; 
 _unit addGoggles 'G_Aviator'; 
 _unit addVest 'V_mas_uk_Rangemaster_belt'; 

....rest of the code

Once I have confirmation that the above is right I will try testing again and I will let you know

Thanks for helping, I really want to find an infallible way to make custom loadouts work in every condition.

cheers

Share this post


Link to post
Share on other sites

No the "_unit setVariable" line that you have in your initPlayerLocal at the moment needs to go at the end of the loadout script (each one).

Share this post


Link to post
Share on other sites

ah damn, I feel pretty noob now ahah , let's see if I get it right this time


_unit = (_this select 0);
if (_unit getVariable ["hasLoadout",false]) exitWith {};


removeallweapons _unit; 
removevest _unit; 
removeuniform _unit; 
removeheadgear _unit;
removeallassigneditems _unit;

sleep 1;

[[{}, _unit addUniform "U_mas_uk_B_IndUniform2_o"], "BIS_fnc_spawn", true] call BIS_fnc_MP; //attention to the syntax here. This, and only this syntax worked for me, even with other resources showing differently

_unit addHeadgear 'H_mas_uk_beret'; 
 _unit addGoggles 'G_Aviator'; 

//....rest of the setup code //

//at the end//  _unit setVariable ["hasLoadout", true, true]; 


if everything is fine, like I said, I put the right corrections, I test and I report back, fingers crossed

Share this post


Link to post
Share on other sites

Yep should be right and should work, but I reserve myself a little (just because Arma logic somedays):).

Share this post


Link to post
Share on other sites

I want to show you the custom-loadout script I used until now

init.sqf

execVM "scripts\client.sqf";

client.sqf

if !(isDedicated) then {

 waitUntil { !IsNull Player };
     if (local player) then {

       waitUntil { time > 8 };

       switch (faction player) do {
              case "mas_ukf_sftg":
              {
              [] call compile preprocessFile "scripts\SASloadouts.sqf";};
              case "mas_usa_mars":
              {
              [] call compile preprocessFile "scripts\USMCloadouts.sqf";};

             };


           switch (player) do {



           case s1: {[s1] call SAS_SL;};
           case s2: {[s2] call SAS_TL;};
           case s3: {[s3] call SAS_RO;};
           case s4: {[s4] call SAS_M;};

           case u1: {[u1] call USMC_SL;};
           case u2: {[u2] call USMC_TL;};
    case u3: {[u3] call USMC_RAT;};
    case u4: {[u4] call USMC_G;};
    case u5: {[u5] call USMC_A;};
    case u6: {[u6] call USMC_MG;};
           };
      };

};  

SASloadouts.sqf

SAS_SL = 
{
 _unit = _this select 0;

removeallweapons _unit; 
removevest _unit; 
removeuniform _unit; 
removeheadgear _unit;
removeallassigneditems _unit;

sleep 1;

[[{}, _unit addUniform "U_mas_uk_B_IndUniform2_m"], "BIS_fnc_spawn", true] call BIS_fnc_MP; //attention to the syntax here. This, and only this syntax worked for me, even with other resources showing differently
_unit addHeadgear 'H_mas_uk_beret'; 
 _unit addGoggles 'G_Aviator'; 
 _unit addVest 'V_mas_uk_Rangemaster_belt'; 
 _unit addBackPack 'B_AssaultPack_cbr'; 
 _unit addmagazine '13Rnd_mas_9x21_Mag'; 

 _unit addmagazine 'CUP_30Rnd_556x45_Stanag'; 
 _unit addweapon 'CUP_arifle_Mk16_CQC_FG';
 _unit addweapon 'hgun_mas_bhp_F';   
 _unit addweapon 'CUP_LRTV'; 
 _unit addPrimaryWeaponItem 'CUP_muzzle_snds_SCAR_L'; 
 _unit addPrimaryWeaponItem 'CUP_acc_ANPEQ_15'; 
 _unit addPrimaryWeaponItem 'CUP_optic_ELCAN_SpecterDR'; 
 _unit addHandgunItem 'muzzle_mas_snds_L'; 
 _unit addItemToUniform 'FirstAidKit'; 
 _unit addItemToUniform 'FirstAidKit'; 
 _unit addItemToUniform '13Rnd_mas_9x21_Mag'; 
 _unit addItemToUniform '13Rnd_mas_9x21_Mag'; 
 _unit addItemToUniform 'B_IR_Grenade'; 
 _unit addItemToUniform 'SmokeShell'; 
 _unit addItemToUniform 'SmokeShell'; 
 _unit addItemToUniform 'SmokeShell'; 
 _unit addItemToUniform 'HandGrenade'; 
 _unit addItemToVest 'CUP_30Rnd_556x45_Stanag'; 
 _unit addItemToVest 'CUP_30Rnd_556x45_Stanag'; 
 _unit addItemToVest 'CUP_30Rnd_556x45_Stanag'; 
 _unit addItemToVest 'CUP_30Rnd_556x45_Stanag'; 
 _unit addItemToVest 'CUP_30Rnd_556x45_Stanag'; 
 _unit addItemToVest 'CUP_30Rnd_556x45_Stanag'; 
 _unit addItemToVest 'CUP_30Rnd_556x45_Stanag'; 
 _unit addItemToVest 'CUP_30Rnd_556x45_Stanag'; 
 _unit addItemToVest '13Rnd_mas_9x21_Mag'; 
 _unit addItemToVest '13Rnd_mas_9x21_Mag'; 
 _unit addItemToVest '13Rnd_mas_9x21_Mag'; 
 _unit addItemToVest '13Rnd_mas_9x21_Mag'; 
 _unit addItemToVest 'SmokeShell'; 
 _unit addItemToVest 'SmokeShell'; 
 _unit addItemToBackpack 'HandGrenade'; 
 _unit addItemToBackpack 'HandGrenade'; 
 _unit addItemToBackpack 'HandGrenade'; 
 _unit addItemToBackpack 'SmokeShellRed'; 
 _unit addItemToBackpack 'SmokeShellRed'; 
 _unit addItemToBackpack 'SmokeShellGreen'; 
 _unit addItemToBackpack 'SmokeShellGreen'; 
 _unit addItemToBackpack 'SmokeShellPurple'; 
 _unit addItemToBackpack 'SmokeShellPurple'; 
 _unit addItemToBackpack 'Chemlight_green'; 
 _unit addItemToBackpack 'Chemlight_red'; 
 _unit addItemToBackpack 'CUP_30Rnd_556x45_Stanag'; 
 _unit addItemToBackpack 'CUP_30Rnd_556x45_Stanag'; 
 _unit addItemToBackpack 'CUP_30Rnd_556x45_Stanag'; 
 _unit addItemToBackpack 'CUP_30Rnd_556x45_Stanag'; 
 _unit linkItem 'ItemMap'; 
 _unit linkItem 'ItemCompass'; 
 _unit linkItem 'ItemWatch'; 
 _unit linkItem 'ItemRadio'; 
 _unit linkItem 'ItemGPS'; 
 _unit linkItem 'NVGoggles_mas_h'; 
 _unit linkItem 'CUP_LRTV'; 


};

SAS_TL =
{
 _unit = _this select 0;

//.....etc etc//

However the script above is not without problems, first one BIG problem is that is not 100% reliable, you have most of the players joining you with correct loadout loaded and other where custom-loadout failed to load, and apparently, to me, look like it happen randomly, sometime player X loads the custom-loadout and sometime not etc.

Second problem is that it load the custom-loadout just for human players and not for the AI.

So basically in months I have found no 100% reliable and always-working custom-loadout script, now I'am hoping in your script or finding a way to make the above working in all conditions.

I just find "weird" to say the last that making custom-loadouts in AIII give all these problems : (

Luckily enought there are people like you helping or I would have already stopped making missions for AIII sigh/lol

Edited by HaZZarD

Share this post


Link to post
Share on other sites

Hey mate, we tested your method today , with last modficiations set in place, all in all I say it works better, not sure if placebo effect but there are more probabilities of players spawning with the right custom loadout loaded, hower in some cases, some people failed to load the custom loadout so I had to restart the mission 2 or 3 times, wait for them to press continue and then start it and at second/third restart all had their custom equip loaded with no apparently issues.

I'am happy with the improvements but still no luck in having something 100% working, are further changes/improvements possible ?

What do you think about putting more than 0 as wait time ? something like

waitUntil {!isNull player};
waitUntil {time > 1};

would it make sense ?

Now I'am not 100% sure of this but look like players with worst performances have less probabilities to load the custom loadout

Another question, can we create a "loop", a continue check, untill sure that " _nul = [s1] execVM "loadout1.sqf"; " etc. are loaded correctly ?

Maybe something that keep doing "_nul = [s1] execVM "loadoutX.sqf" untill sure that the loadout is loaded, so a variable is returned as true ?

Now I don't know much about scripting so I just put ideas there, I really want to find a solution and then share it with other people

cheers

Share this post


Link to post
Share on other sites

Try 5 on the waitUntil time > # line, just because, and you could do this to ensure each script is completed:

_scriptFinished = [s1] execVM "loadout.sqf";
waitUntil {scriptDone _scriptFinished};

Share this post


Link to post
Share on other sites
Try 5 on the waitUntil time > # line, just because, and you could do this to ensure each script is completed:

_scriptFinished = [s1] execVM "loadout.sqf";
waitUntil {scriptDone _scriptFinished};

should I put that before triggering each loadout script ? like below ?

waitUntil {!isNull player};
waitUntil {time > 5};


_scriptFinished = [s1] execVM "loadout1.sqf";
waitUntil {scriptDone _scriptFinished};

_nul = [s1] execVM "loadout1.sqf";

_scriptFinished = [s2] execVM "loadout2.sqf";
waitUntil {scriptDone _scriptFinished};

_nul = [s2] execVM "loadout2.sqf";

Edited by HaZZarD

Share this post


Link to post
Share on other sites

Yea but more like this for the rest of the loadouts:

waitUntil {!isNull player};
waitUntil {time > 5};


_scriptFinished = [s1] execVM "loadout1.sqf";
waitUntil {scriptDone _scriptFinished};

_scriptFinished = [s2] execVM "loadout1.sqf";

_scriptFinished = [s3] execVM "loadout2.sqf";
waitUntil {scriptDone _scriptFinished};

_scriptFinished = [s4] execVM "loadout2.sqf";
waitUntil {scriptDone _scriptFinished};

Share this post


Link to post
Share on other sites

I have something interesting to show you from last tests, before trying your last suggested modification.

We made these tests with even waitUntil {time > 60}; , so waiting for the player to take control of the character didn't fix things for now.

http://i.imgur.com/dXKj8Rd.jpg

Top left you have the basic vanilla loadout that comes with the mod

Top right you have my custom loadout, always working for me as host in MP

Below you see what happen to a player joining me, not even in progress, I waited for him to press continue

his loadout is a total mess with a mix of vanilla stuff (red cross) and from my custom loadout stuff (green check), items not marked are those in common with both setups.

I will try your last suggested modifications and report back

Edited by HaZZarD

Share this post


Link to post
Share on other sites

No luck, even with last addition still some players are unable to load the setup right, for now I will find a workaround like players getting the equip from vehicles, via add-action script

thanks for helping and I hope BIS will take a look at custom loadouts in AIII because right now it's too messy, too many problems

cheers

Edited by HaZZarD

Share this post


Link to post
Share on other sites

TBH I don't really know what could be causing this issue because my redressing script is essentially a "loadout" script in a sense and I don't have any issues with it (AFAIK).

I would make sure you have -showScriptErrors enabled on Steam startup and see if any errors are thrown while running the code.

Share this post


Link to post
Share on other sites
No luck, even with last addition still some players are unable to load the setup right, for now I will find a workaround like players getting the equip from vehicles, via add-action script

thanks for helping and I hope BIS will take a look at custom loadouts in AIII because right now it's too messy, too many problems

cheers

As a newbie in scripting and after trying different stuff, i have found a solution to a similar problem that i had with by using BIS_fnc_addRespawnInventory.

It works like this :

1. On the Description.ext i have placed the following code.

respawn = "BASE";
respawnDelay = 10;
respawnTemplates[] = {"MenuInventory","MenuPosition"};
respawnOnStart = 1;
onLoadName = "Testing Stuff";
loadScreen = "";
disabledAI = 1;
disableChannels[]={6};  //set {0,6} to disable global
enableSaving = [false, false];

class CfgRespawnInventory
{

  class Gear1
{
	displayName = "Loadout01"; // Name visible in the menu
	icon = "\A3\Ui_f\data\GUI\Cfg\Ranks\private_gs.paa"; // Icon displayed next to the name

	// Loadout definition, uses same entries as CfgVehicles classes
	weapons[] = {
		"Binocular",
		"hgun_Pistol_heavy_01_F"
	};
	magazines[] = {
		"11Rnd_45ACP_Mag",
		"11Rnd_45ACP_Mag",
		"11Rnd_45ACP_Mag",
		"11Rnd_45ACP_Mag",
		"11Rnd_45ACP_Mag"
		};
	items[] = {
		"FirstAidKit"
		};
	linkedItems[] = {
		"H_Watchcap_blk",
		"optic_MRD",
		"muzzle_snds_acp",
		"NVGoggles",
		"G_Sport_BlackWhite",
		"ItemMap",
		"ItemCompass",
		"ItemWatch",
		"ItemRadio"
	};
	uniformClass = "U_I_G_Story_Protagonist_F";
	backpack = "B_FieldPack_blk";
}; 
class Gear2
 	{
  	displayName = "loadout02";
  	icon = "\A3\Ui_f\data\GUI\Cfg\Ranks\corporal_gs.paa";

	weapons[] = {
		"Binocular",
		"arifle_MXM_Black_F"
	};
	magazines[] = {
		"30Rnd_65x39_caseless_mag",
		"30Rnd_65x39_caseless_mag",
		"30Rnd_65x39_caseless_mag",
		"30Rnd_65x39_caseless_mag",
		"30Rnd_65x39_caseless_mag"
		};
	items[] = {
		"FirstAidKit"
		};
	linkedItems[] = {
		"H_Watchcap_blk",
		"optic_MRD",
		"muzzle_snds_acp",
		"NVGoggles",
		"G_Sport_BlackWhite",
		"ItemMap",
		"ItemCompass",
		"ItemWatch",
		"ItemRadio"
	};
	uniformClass = "U_I_G_Story_Protagonist_F";
	backpack = "B_FieldPack_blk";



}; 		
};

2. After i have done the above i have created a loadout.sqf file which contains :

LoadOut01 = 
{
	[west, "Gear1"] call BIS_fnc_addRespawnInventory;
	[east, "Gear1"] call BIS_fnc_addRespawnInventory;
	[civilian, "Gear1"] call BIS_fnc_addRespawnInventory;              
	[resistance, "Gear1"] call BIS_fnc_addRespawnInventory;

};
LoadOut02 =
{
	[west, "Gear2"] call BIS_fnc_addRespawnInventory;
	[east, "Gear2"] call BIS_fnc_addRespawnInventory;
	[civilian, "Gear2"] call BIS_fnc_addRespawnInventory;
	[resistance, "Gear2"] call BIS_fnc_addRespawnInventory;


};

3. I have created another sqf file called "CallingLoadout.sqf". Inside i have simply :

[player] call LoadOut01
[player] call LoadOut02

4. i am calling the above script in init.sqf with

execVM "loadout.sqf";
execVM "CallingLoadout.sqf";

By having on description.ext respawnOnStart = 1; and respawnTemplates[] = {"MenuInventory","MenuPosition"}; i can choose the loadout that i want for my unit. Hope that i could help you a bit with the above.

Since i cannot create a thread of my own since i am new to the forum, i might as well ask here and hope that someone can help me. I have the scripts above. I have also created a small rank framework. My question is how can i connect the different loadouts with a rank. For example : My start gear as private rank is the LoadOut01. Once i reach the corporal rank i want to have access to Loadout02 etc. Is there a simple way to achieve that with the above ? Many thanks in advance for the help someone can provide.

Regards

Seed

PS: Sorry for my English

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
Sign in to follow this  

×