Jump to content
Sign in to follow this  
Lewis909

Will this loadout script work?

Recommended Posts

Hi just creating a test loadout .sqf. This is my first attempt and I was wondering if it will work, currently at work so I can't test it.

////Main Loadout
removeAllWeapons this;
{this addMagazine ["30Rnd_556x45_Stanag",5]};
this addWeapon "M4A3_CCO_EP1";
{this addMagazine ["HandGrenade_West",5]};
this addWeapon "Binocular";
this addWeapon "NVGoggles";
this addWeapon "ItemGPS";


////Back Pack load out
learMagazineCargo (unitBackpack this);
(unitBackpack this) addMagazineCargo ["Laserbatteries",10]; 

Cheers

Share this post


Link to post
Share on other sites

Well, I dont think you need those extra breckets for magazines. You are missing c for clearMagazineCargo. Use it like this

removeAllWeapons this;
removeBackpack this;
this addBackpack "DE_Backpack_Specops_EP1";
clearMagazineCargo (unitBackpack this);
unitBackpack this addMagazineCargo ["30Rnd_556x45_Stanag",6];
unitBackpack this addMagazineCargo ["PipeBomb",2];
unitBackpack this addMagazineCargo ["Mine",2];
//Primary
this addMagazine "30Rnd_556x45_Stanag";
this addMagazine "30Rnd_556x45_Stanag";
this addMagazine "30Rnd_556x45_Stanag";
this addMagazine "30Rnd_556x45_Stanag";
this addMagazine "30Rnd_556x45_Stanag";
this addMagazine "30Rnd_556x45_Stanag";
this addMagazine "30Rnd_556x45_Stanag";
this addMagazine "30Rnd_556x45_Stanag";
this addMagazine "PipeBomb";
this addMagazine "HandGrenade_West";
this addMagazine "Laserbatteries";
this addWeapon "M4A3_CCO_EP1";
//Equipment
this addWeapon "Laserdesignator";
this addWeapon "NVGoggles";
this selectWeapon "M4A3_CCO_EP1";

Now, if you gonna run this from init.sqf or something you probably need to tell the game what "this" is. Like player or unit name.

If you use search button you can find a lot of scripts for this and they even save your loadout, etc.

Edited by 11aTony

Share this post


Link to post
Share on other sites

Np. The addXXX commands doesn't work with arrays unless it is addXXXCargo (to a vehicle). Do multiple lines or a forEach loop to add more than one of an item. Also, no need to put anything here in their own {} scope.

But, do your scripts at a machine you can test them on. Especially on this (learning) level. In any case, check out others loadout scripts and do as they do.

Share this post


Link to post
Share on other sites
Well, I dont think you need those extra breckets for magazines. You are missing c for clearMagazineCargo. Use it like this

removeAllWeapons this;
removeBackpack this;
this addBackpack "DE_Backpack_Specops_EP1";
clearMagazineCargo (unitBackpack this);
unitBackpack this addMagazineCargo ["30Rnd_556x45_Stanag",6];
unitBackpack this addMagazineCargo ["PipeBomb",2];
unitBackpack this addMagazineCargo ["Mine",2];
//Primary
this addMagazine "30Rnd_556x45_Stanag";
this addMagazine "30Rnd_556x45_Stanag";
this addMagazine "30Rnd_556x45_Stanag";
this addMagazine "30Rnd_556x45_Stanag";
this addMagazine "30Rnd_556x45_Stanag";
this addMagazine "30Rnd_556x45_Stanag";
this addMagazine "30Rnd_556x45_Stanag";
this addMagazine "30Rnd_556x45_Stanag";
this addMagazine "PipeBomb";
this addMagazine "HandGrenade_West";
this addMagazine "Laserbatteries";
this addWeapon "M4A3_CCO_EP1";
//Equipment
this addWeapon "Laserdesignator";
this addWeapon "NVGoggles";
this selectWeapon "M4A3_CCO_EP1";

Now, if you gonna run this from init.sqf or something you probably need to tell the game what "this" is. Like player or unit name.

If you use search button you can find a lot of scripts for this and they even save your loadout, etc.

I got his working in the init line of a unit. I would like this to be triggered via a .sqf file so I can easily edit it outside of the game.

I have looked everywhere and I can't seem to find out how to execute the .sqf file.

basically I want to have different loadout .sqf's and get different units to use them depending on the setup that I want.

I hop this makes sense.

Cheers

Share this post


Link to post
Share on other sites

I have looked everywhere and I can't seem to find out how to execute the .sqf file.

this exec "myfile.sqf" in any objects/units init line

but you have to change all the "this" into the name of the unit

Edit:

Oh . yes its a .sqf not .sqs

Edited by davincy81

Share this post


Link to post
Share on other sites

try my presets loadouts in my sig spoiler, its just what you want.

for information:

I have looked everywhere and I can't seem to find out how to execute the .sqf file.

save your script as yourscriptname.sqf

now you can execute that script with:

_null = [this] execVM "yourscriptname.sqf";

for your script you need to do some changes when used in a script.

add this to top:

_unit = _this select 0;

change all this to _unit.

Share this post


Link to post
Share on other sites

So the script will look like this:


_unit = _this select 0;

removeAllWeapons this;
removeBackpack this;
this addBackpack "DE_Backpack_Specops_EP1";
clearMagazineCargo (unitBackpack this);
unitBackpack this addMagazineCargo ["30Rnd_556x45_Stanag",6];
unitBackpack this addMagazineCargo ["PipeBomb",2];
unitBackpack this addMagazineCargo ["Mine",2];
//Primary
_unit addMagazine "30Rnd_556x45_Stanag";
_unit addMagazine "30Rnd_556x45_Stanag";
_unit addMagazine "30Rnd_556x45_Stanag";
_unit addMagazine "30Rnd_556x45_Stanag";
_unit addMagazine "30Rnd_556x45_Stanag";
_unit addMagazine "30Rnd_556x45_Stanag";
_unit addMagazine "30Rnd_556x45_Stanag";
_unit addMagazine "30Rnd_556x45_Stanag";
_unit addMagazine "PipeBomb";
_unit addMagazine "HandGrenade_West";
_unit addMagazine "Laserbatteries";
_unit addWeapon "M4A3_CCO_EP1";
//Equipment
_unit addWeapon "Laserdesignator";
_unit addWeapon "NVGoggles";
_unit selectWeapon "M4A3_CCO_EP1";

And in the Units init I place:

_null = [this] execVM "yourscriptname.sqf";

?

Share this post


Link to post
Share on other sites

Ahhh so I need to change the "This" in the Remove Weapons Backpack section and "This", in the Backpack AddWeapon etc.?

Thanks so much for your help.

Cheers

Share this post


Link to post
Share on other sites

You can use

{_unit addMagazine "30Rnd_556x45_Stanag"} forEach [1,2,3,4,5,6,7,8];

for example so you don't put each mag in a separate line. This will add 8 mags for your M4.

Always add the ammo before the weapon so it is loaded on first use.

If you put a second primary in the back pack, add at least one of it's mags in there so it is loaded after you switch.

Also leave an empty slot in the backpack or you will drop ammo when you switch.

Example is my loadout triggered after an ID check:

	_MyUnit = player; 
// Main Slot clearance	
removeAllWeapons _MyUnit;
removeAllItems _MyUnit;
removeBackpack _MyUnit;

// Equipment stocking
_MyUnit addWeapon "NVGoggles";
_MyUnit addMagazine "Laserbatteries";
_MyUnit addWeapon "Laserdesignator";
_MyUnit addWeapon "ItemMap";
_MyUnit addWeapon "ItemGPS";
_MyUnit addWeapon "ItemCompass";	
_MyUnit addWeapon "ItemRadio";
_MyUnit addWeapon "ItemWatch";

// Primary and Secondary stocking
{_MyUnit addMagazine "PipeBomb"} forEach [1];
{_MyUnit addMagazine "SmokeShellred"} forEach [1];
{_MyUnit addMagazine "SmokeShell"} forEach [1];
{_MyUnit addMagazine "SmokeShellblue"} forEach [1];
{_MyUnit addMagazine "30Rnd_556x45_G36SD"} forEach [1,2,3,4,5,6];
_MyUnit addWeapon "m8_tws_sd";

// Side & NoobToob Ammo slot stocking	
{_MyUnit addMagazine "17Rnd_9x19_glock17"} forEach [1,2,3,4,5,6,7,8];
_MyUnit addWeapon "glock17_EP1";

//Backpack Selection & Slot clearance
player addBackpack "BAF_Assaultpack_Special";
_MyBackpack = unitBackpack _MyUnit;
clearWeaponCargo (unitBackpack _MyUnit);
clearMagazineCargo (unitBackpack _MyUnit);

// Backpack slot stocking
// If you want your backpack stored weapon to be loaded when selected,
// you need to store one of it's mags in the pack also.
// If you do place a gun & ammo in the backpack,
// leave one empty slot or you will drop ammo on weapon switch.
_MyBackpack addMagazineCargo ["PipeBomb",2];	
_MyBackpack addMagazineCargo ["30Rnd_556x45_G36SD",8];
};  

Edited by Liquidpinky
example given

Share this post


Link to post
Share on other sites

Thanks Liquid Pink it works perfectly.

Cheers Guys and thanks fro the help.

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  

×