Jump to content
Sign in to follow this  
neven

Unit Loadout Syntax - sqf

Recommended Posts

I'm having so much fun with the Alpha. Thanks for releasing it for us to work with and review. I have looked for an hour for this answer, and I can't seem to find it.

I have created an sqf file to use with my units.

I seem to have all of the attributes defined for the load-out except the Handgun Ammo isn't working for me. Can you review my syntax for the Handgun Ammo and offer any direction.

In addition, the Unit is forced to reload the primary weapon upon mission start. Is it possible to have a clip already loaded into the primary weapon?

And lastly, can you also add the syntax for adding a HandGrenade.

_unit addmagazine "HandGrenade";

Addweapon, AddMagazine/s, and AddItem, don't seem to be working for me for adding HandGrenade.

Thank-you very much.


// 1: Copy/Paste this code into a simple text file and save it as teamleader.sqf in your edited missions folder.

// 2: Copy/Paste in Unit Initialization:  nul = [this] execVM "teamleader.sqf";


// LOADOUT - TEAM LEADER
_unit = _this select 0;
removeallweapons _unit;
removeallassigneditems _unit;
removeallcontainers _unit;

//Gear
_unit addHeadGear "H_HelmetB";
_unit addUniform "U_O_CombatUniform_ocamo";
_unit addweapon "Binocular";
_unit additem "ItemCompass"; _unit assignItem "ItemCompass";
_unit additem "ItemGPS"; _unit assignItem "ItemGPS";
_unit additem "G_Sport_Blackred"; _unit assignItem "G_Sport_Blackred";
_unit additem "ItemMap"; _unit assignItem "ItemMap";
_unit additem "ItemRadio"; _unit assignItem "ItemRadio";
_unit additem "ItemWatch"; _unit assignItem "ItemWatch";
_unit additem "NVGoggles"; _unit assignItem "NVGoggles";

//Meds
_unit additem "FirstAidKit"; _unit additem "FirstAidKit"; _unit additem "FirstAidKit"; _unit additem "FirstAidKit"; 

// Primary
_unit addweapon "LMG_Mk200_ACO_grip_F" ;
_unit addPrimaryWeaponItem "muzzle_snds_H_MG";
_unit addprimaryweaponitem "optic_Hamr";
_unit addprimaryweaponitem "acc_flashlight";

//Secondary
_unit addweapon "hgun_rook40_F";
//-----NOT WORKING-----------_unit addmagazines ["16rnd_9x21_mag",1];

//Ammo
_unit addmagazine "SmokeShell";
_unit addbackpack "B_Carryall_ocamo";
_unit addmagazines ["DemoCharge_Remote_Mag",2];
_unit addVest "V_TacVest_khk";
_unit addmagazines ["200Rnd_65x39_cased_Box_Tracer",6];
_unit addmagazines ["APERSBoundingMine_Range_Mag",3];
_unit addmagazines ["NLAW_F",1];

//Launcher

_unit addweapon "launch_NLAW_F";


Oh... I'm also using the updated version on Steam if that makes a difference.

Edited by neven
Updated that I'm using the dev version.

Share this post


Link to post
Share on other sites

If you want weapon to come loaded, you need to add magazine first.

Share this post


Link to post
Share on other sites
If you want weapon to come loaded, you need to add magazine first.

It is indeed added and available. If you look in my sqf code it's there.

_unit addmagazines ["200Rnd_65x39_cased_Box_Tracer",6];

But when the mission starts, the soldier simply needs to reload. So the question is, in addition to the 2 other issues, is how to make the primary rifle already loaded with one of the magazines in inventory.

Share this post


Link to post
Share on other sites

First you do: _unit addweapon "LMG_Mk200_ACO_grip_F" ;

Then: _unit addmagazines ["200Rnd_65x39_cased_Box_Tracer",6];

That means you do add magazine after adding weapon, thus your weapon is not added loaded.

Here, moved the ammo section so all magazines are added prior to adding weapons.

// 1: Copy/Paste this code into a simple text file and save it as teamleader.sqf in your edited missions folder.

// 2: Copy/Paste in Unit Initialization:  nul = [this] execVM "teamleader.sqf";


// LOADOUT - TEAM LEADER
_unit = _this select 0;
removeallweapons _unit;
removeallassigneditems _unit;
removeallcontainers _unit;

//Gear
_unit addHeadGear "H_HelmetB";
_unit addUniform "U_O_CombatUniform_ocamo";
_unit addweapon "Binocular";
_unit additem "ItemCompass"; _unit assignItem "ItemCompass";
_unit additem "ItemGPS"; _unit assignItem "ItemGPS";
_unit additem "G_Sport_Blackred"; _unit assignItem "G_Sport_Blackred";
_unit additem "ItemMap"; _unit assignItem "ItemMap";
_unit additem "ItemRadio"; _unit assignItem "ItemRadio";
_unit additem "ItemWatch"; _unit assignItem "ItemWatch";
_unit additem "NVGoggles"; _unit assignItem "NVGoggles";

//Meds
_unit additem "FirstAidKit"; _unit additem "FirstAidKit"; _unit additem "FirstAidKit"; _unit additem "FirstAidKit"; 

//Ammo
_unit addmagazines ["16Rnd_9x21_Mag",1];
_unit addmagazine "SmokeShell";
_unit addbackpack "B_Carryall_ocamo";
_unit addmagazines ["DemoCharge_Remote_Mag",2];
_unit addVest "V_TacVest_khk";
_unit addmagazines ["200Rnd_65x39_cased_Box_Tracer",6];
_unit addmagazines ["APERSBoundingMine_Range_Mag",3];
_unit addmagazines ["NLAW_F",1];
_unit addmagazine "HandGrenade";

// Primary
_unit addweapon "LMG_Mk200_ACO_grip_F" ;
_unit addPrimaryWeaponItem "muzzle_snds_H_MG";
_unit addprimaryweaponitem "optic_Hamr";
_unit addprimaryweaponitem "acc_flashlight";

//Secondary
_unit addweapon "hgun_rook40_F";


//Launcher
_unit addweapon "launch_NLAW_F";

Also team/squad leader soldiers sometimes have bugged grenades. Try to add this on top of the script.

waitUntil { !isNull player }; 
sleep 1; // If it still doesn't work add more sleep D:

Edited by aeroson

Share this post


Link to post
Share on other sites

Thanks a bunch. I should have realized it is hierarchical. Everything seems to be working now, only except the ammo for the handgun isn't present in the gear at all. I see that you added it to the ammo.

The vest needs to also be before the handgun ammo in order for it to work. Here's the full working version:


// 1: Copy/Paste this code into a simple text file and save it as teamleader.sqf in your edited missions folder.

// 2: Copy/Paste in Unit Initialization:  nul = [this] execVM "teamleader.sqf";


// LOADOUT - TEAM LEADER
_unit = _this select 0;
removeallweapons _unit;
removeallassigneditems _unit;
removeallcontainers _unit;

//Gear
_unit addHeadGear "H_HelmetB";
_unit addUniform "U_B_CombatUniform_mcam_vest";
_unit addVest "V_TacVest_khk";
_unit addbackpack "B_Carryall_ocamo";
_unit addweapon "Binocular";
_unit additem "ItemCompass"; 
_unit assignItem "ItemCompass";
_unit additem "ItemGPS"; 
_unit assignItem "ItemGPS";
_unit additem "G_Sport_Blackred"; 
_unit assignItem "G_Sport_Blackred";
_unit additem "ItemMap"; _unit assignItem "ItemMap";
_unit additem "ItemRadio"; _unit assignItem "ItemRadio";
_unit additem "ItemWatch"; _unit assignItem "ItemWatch";
_unit additem "NVGoggles"; _unit assignItem "NVGoggles";
_unit additem "acc_pointer_IR";


//Ammo
_unit addmagazine "SmokeShell";_unit addmagazine "SmokeShellRed";
_unit addmagazine "Chemlight_blue";_unit addmagazine "Chemlight_yellow";_unit addmagazine "Chemlight_blue";_unit addmagazine "Chemlight_yellow";
_unit addmagazine "HandGrenade"; _unit addmagazine "HandGrenade";
_unit addmagazines ["DemoCharge_Remote_Mag",2];
_unit addmagazines ["200Rnd_65x39_cased_Box_Tracer",8];
_unit addmagazines ["16rnd_9x21_mag",2];
_unit addmagazines ["APERSTripMine_Wire_Mag",3];
_unit addmagazines ["NLAW_F",1];



//Meds
_unit additem "FirstAidKit"; _unit additem "FirstAidKit"; _unit additem "FirstAidKit"; _unit additem "FirstAidKit"; _unit additem "FirstAidKit"; _unit additem "FirstAidKit"; _unit additem "FirstAidKit"; _unit additem "FirstAidKit"; 

// Primary
_unit addweapon "LMG_Mk200_ACO_grip_F" ;
_unit addPrimaryWeaponItem "muzzle_snds_H_MG";
_unit addprimaryweaponitem "optic_Hamr";
_unit addprimaryweaponitem "acc_flashlight";

//Secondary
_unit addweapon "hgun_rook40_F";

//Launcher
_unit addweapon "launch_NLAW_F";

Thanks a bunch.

Edited by neven

Share this post


Link to post
Share on other sites

Rather than starting another thread on the loadout subject. Can you please advise me on the proper syntax for using an external sqf with an ammo crate? I have the Bluefor ammo crate below and I would like to call it using a .sqf, but the syntax doesn't seem to be working as it does for a unit. Such as:

nul = [this] execVM "blueforammo.sqf"; 

Not working :confused:

Currently I am forced to copy/paste the following ammo crate script in to each crate by hand which is painful to update. Thanks again for any direction!

BLUEFOR CUSTOM AMMO CRATE: name: bluforammo.sqf

removeallweapons _this; 
removeallassigneditems _this;
Removeuniform _this;
removeVest _this;
_this addWeaponCargo ["Binocular", 25];
_this addMagazineCargo ["200Rnd_65x39_cased_Box_Tracer", 20];
_this addItemCargo ["FirstAidKit", 25];
_this addItemCargo ["ItemCompass", 25];
_this addItemCargo ["ItemGPS", 25];
_this addItemCargo ["ItemMap", 25];
_this addItemCargo ["ItemRadio", 25];
_this addItemCargo ["ItemWatch", 25];
_this addItemCargo ["Medikit", 25];
_this addItemCargo ["MineDetector", 25];
_this addItemCargo ["ToolKit", 25];
_this addweaponcargo ["hgun_P07_F", 20];
_this addMagazineCargo ["30Rnd_65x39_caseless_green_mag_Tracer", 50];
_this addweaponcargo ["srifle_EBR_F", 20];
_this addweaponcargo ["LMG_Mk200_F", 20];
_this addMagazineCargo ["200Rnd_65x39_cased_Box_Tracer", 40];
_this addMagazineCargo ["30Rnd_65x39_case_mag", 40];
_this addbackpackcargo ["B_AssaultPack_blk", 10];   
_this addbackpackcargo ["B_AssaultPack_dgtl", 10];   
_this addbackpackcargo ["B_AssaultPack_rgr_Medic", 10];   
_this addbackpackcargo ["B_AssaultPack_rgr_Repair", 10];       
_this addbackpackcargo ["B_Carryall_Base", 10];          
_this addMagazinecargo ["Chemlight_green", 60];   
_this addMagazinecargo ["Chemlight_red", 60];   
_this addMagazinecargo ["Chemlight_yellow", 60];   
_this addMagazinecargo ["Chemlight_blue", 60];   
_this addMagazinecargo ["HandGrenade", 60];   
_this addMagazinecargo ["1Rnd_HE_Grenade_shell", 100];  
_this addMagazinecargo ["3Rnd_HE_Grenade_shell", 60];   
_this addMagazinecargo ["1Rnd_Smoke_Grenade_shell", 60];   
_this addMagazinecargo ["3Rnd_Smoke_Grenade_shell", 60];   
_this addMagazinecargo ["1Rnd_SmokeBlue_Grenade_shell", 60];   
_this addMagazinecargo ["3Rnd_SmokeBlue_Grenade_shell", 60];   
_this addMagazinecargo ["8Rnd_12Gauge_Pellets", 60];   
_this addweaponcargo ["launch_NLAW_F", 60];   
_this addweaponcargo ["launch_RPG32_F", 60];   
_this addweaponcargo ["arifle_MXC_Holo_point_grip_snds_F", 60];    
_this addweaponcargo ["arifle_Khaybar_GL_ACO_point_mzls_F", 60];      
_this addMagazinecargo ["NLAW_F", 60];      
_this addMagazinecargo ["3Rnd_UGL_FlareGreen_F", 60];    
_this addMagazinecargo ["3Rnd_UGL_FlareCIR_F", 60];    
_this addMagazinecargo ["3Rnd_UGL_FlareRed_F", 60];      
_this additemcargo ["NVGoggles", 60];       
_this addMagazinecargo ["3Rnd_UGL_FlareWhite_F", 60];    
_this addMagazinecargo ["3Rnd_UGL_FlareYellow_F", 60];    
_this addMagazinecargo ["FlareGreen_F", 60];    
_this addMagazinecargo ["FlareRed_F", 60];    
_this addMagazinecargo ["FlareWhite_F", 60];    
_this addMagazinecargo ["FlareYellow_F", 60];    
_this addMagazinecargo ["UGL_FlareGreen_F", 60];    
_this addMagazinecargo ["UGL_FlareCIR_F", 60];    
_this addMagazinecargo ["UGL_FlareRed_F", 60];     
_this addMagazinecargo ["20rnd_762x45_mag", 60];    
_this addMagazinecargo ["RPG32_AA_F", 60];     
_this addMagazinecargo ["30Rnd_9x21_Mag_vector_Tracer_Green", 60];    
_this addweaponcargo ["arifle_MX_GL_F", 60];  
_this addweaponcargo ["arifle_TRG21_GL_F", 60]; 
_this addweaponcargo ["srifle_EBR_F", 60];  
_this addMagazinecargo ["30Rnd_65x39_Caseless_mag", 100]; 
_this addMagazinecargo ["100Rnd_65x39_Caseless_mag", 100]; 
_this addMagazinecargo ["30Rnd_65x39_caseless_mag_Tracer", 100]; 
_this addMagazinecargo ["100Rnd_65x39_caseless_mag_Tracer", 100]; 
_this addMagazinecargo ["30Rnd_65x39_case_mag", 100];  
_this addMagazinecargo ["16Rnd_9x21_Mag", 100]; 
_this addMagazinecargo ["30Rnd_9x21_Mag", 100];   
_this addMagazinecargo ["30RND_556x45_Stanag", 100];  
_this addmagazinecargo ["ATMine_Range_Mag", 60]; 
_this addmagazinecargo ["APERSMine_Range_Mag", 60]; 
_this addmagazinecargo ["ClaymoreDirectionalMine_Remote_Mag", 60]; 
_this addmagazinecargo ["DemoCharge_Remote_Mag", 60]; 
_this addmagazinecargo ["APERSBoundingMine_Range_Mag", 60]; 
_this addmagazinecargo ["SLAMDirectionalMine_Wire_Mag", 60]; 
_this addmagazinecargo ["APERSTripMine_Wire_Mag", 60];
_this additemcargo ["Zasleh2",60]; 
_this additemcargo ["muzzle_snds_H", 60]; 
_this additemcargo ["muzzle_snds_L", 60]; 
_this additemcargo ["muzzle_snds_B", 60]; 
_this additemcargo ["muzzle_snds_H_MG", 60]; 
_this additemcargo ["optic_Arco", 60]; 
_this additemcargo ["optic_Hamr", 60]; 
_this additemcargo ["optic_Aco", 60]; 
_this additemcargo ["optic_ACO_grn",60]; 
_this additemcargo ["optic_Holosight", 60]; 
_this additemcargo ["acc_flashlight", 60]; 
_this additemcargo ["acc_pointer_IR", 60];
_this additemcargo ["U_BasicBody", 60]; 
_this additemcargo ["U_B_CombatUniform_mcam", 60]; 
_this additemcargo ["U_B_CombatUniform_mcam_tshirt", 60]; 
_this additemcargo ["U_B_CombatUniform_mcam_vest", 60];  
_this additemcargo ["U_Rangemaster", 60];
_this additemcargo ["V_Rangemaster_belt", 60]; 
_this additemcargo ["V_BandollierB_khk", 60]; 
_this additemcargo ["V_BandollierB_rgr", 60]; 
_this additemcargo ["V_BandollierB_cbr", 60]; 
_this additemcargo ["V_PlateCarrier1_rgr", 60]; 
_this additemcargo ["V_PlateCarrier1_cbr", 60]; 
_this additemcargo ["V_PlateCarrier2_rgr", 60]; 
_this additemcargo ["V_PlateCarrierGL_rgr", 60]; 
_this additemcargo ["V_Chestrig_khk", 60]; 
_this additemcargo ["V_ChestrigB_rgr", 60]; 
_this additemcargo ["V_TacVest_khk", 60]; 
_this additemcargo ["V_TacVest_brn", 60]; 
_this additemcargo ["V_TacVest_oli", 60]; 
_this additemcargo ["V_HarnessO_brn", 60]; 
_this additemcargo ["V_HarnessOGL_brn", 60]; 
_this additemcargo ["V_RebreatherB", 60]; 
_this additemcargo ["V_RebreatherIR", 60];
_this additemcargo ["H_HelmetB", 60]; 
_this additemcargo ["H_HelmetB_paint", 60]; 
_this additemcargo ["H_HelmetB_light", 60]; 
_this additemcargo ["H_Cap_red", 60]; 
_this additemcargo ["H_Cap_brn_SERO", 60]; 
_this additemcargo ["H_Cap_blu", 60]; 
_this additemcargo ["H_Cap_headphones", 60]; 
_this additemcargo ["H_PilotHelmetHeli_B", 60]; 
_this additemcargo ["H_PilotHelmetHeli_O", 60]; 
_this additemcargo ["H_HelmetO_ocamo", 60]; 
_this additemcargo ["H_MilCap_ocamo", 60]; 
_this additemcargo ["H_MilCap_mcamo", 60]; 

Share this post


Link to post
Share on other sites

If your copy paste is accurate you're executing blueforammo.sqf but your script is named bluforammo.sqf.

Also the correct commands would be clearWeaponCargo, clearMagazineCargo and clearItemCargo. Additionally you can use clearBackpackCargo if you also want to remove backpacks. Add these to the top instead of the "removeallweapons" etc.

Share this post


Link to post
Share on other sites
this execVM "bluforammo.sqf";

Edited by Sanjo

Share this post


Link to post
Share on other sites

I have coop mission but some problems with running scripts, it works fine with AI but when other players do enter game other players start loosing items. Every player/class has unique script and items but how its possible that they are affecting on others?

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  

×