Jump to content
Sign in to follow this  
avibird 1

How can you add weapons to units while spawning into the game using a SQF format?

Recommended Posts

I know how to add weapons to a unit when using the editor ie unit inti box!

but how to I add a weapon to select units within a group that I am spawning into the mission from a SQF ? Here is the SQF

[] exec "AISUPPORT\menu\ci_menu2_close.sqf";
buyinfv2BAF = false;
publicvariable "buyinfv2BAF";

//hq2BAF removeaction 1B;

Groupinf2B = CreateGroup WEST;
infBAF1 = Groupinf2B createUnit ["BAF_Soldier_SL_DDPM", [(getpos player) select 0,(getpos player) select 1,0], [], 35, "FORM"];
infBAF2 = Groupinf2B createUnit ["BAF_Soldier_TL_DDPM", [(getpos player) select 0,(getpos player) select 1,0], [], 30, "FORM"];
infBAF3 = Groupinf2B createUnit ["BAF_Soldier_TL_DDPM", [(getpos player) select 0,(getpos player) select 1,0], [], 30, "FORM"];
infBAF4 = Groupinf2B createUnit ["BAF_Soldier_MG_DDPM", [(getpos player) select 0,(getpos player) select 1,0], [], 30, "FORM"];
infBAF5 = Groupinf2B createUnit ["BAF_Soldier_AR_DDPM", [(getpos player) select 0,(getpos player) select 1,0], [], 30, "FORM"];
infBAF6 = Groupinf2B createUnit ["BAF_Soldier_AT_DDPM", [(getpos player) select 0,(getpos player) select 1,0], [], 30, "FORM"];
infBAF7 = Groupinf2B createUnit ["BAF_Soldier_AT_DDPM", [(getpos player) select 0,(getpos player) select 1,0], [], 30, "FORM"];
infBAF8 = Groupinf2B createUnit ["BAF_Soldier_GL_DDPM", [(getpos player) select 0,(getpos player) select 1,0], [], 30, "FORM"];
infBAF9 = Groupinf2B createUnit ["BAF_Soldier_GL_DDPM", [(getpos player) select 0,(getpos player) select 1,0], [], 30, "FORM"];
infBAF10 = Groupinf2B createUnit ["BAF_Soldier_AT_DDPM", [(getpos player) select 0,(getpos player) select 1,0], [], 30, "FORM"];
infBAF11 = Groupinf2B createUnit ["BAF_Soldier_AT_DDPM", [(getpos player) select 0,(getpos player) select 1,0], [], 30, "FORM"];
infBAF12 = Groupinf2B createUnit ["BAF_Soldier_scout_DDPM", [(getpos player) select 0,(getpos player) select 1,0], [], 30, "FORM"];
infBAF13 = Groupinf2B createUnit ["BAF_Soldier_FAC_DDPM", [(getpos player) select 0,(getpos player) select 1,0], [], 30, "FORM"];
infBAF14 = Groupinf2B createUnit ["BAF_Soldier_AA_DDPM", [(getpos player) select 0,(getpos player) select 1,0], [], 30, "FORM"];
infBAF15 = Groupinf2B createUnit ["BAF_Soldier_Medic_DDPM", [(getpos player) select 0,(getpos player) select 1,0], [], 30, "FORM"];
infUN1 = leader Groupinf2B;
{_x setSkill 1} foreach units Groupinf2B;

wp1 = Groupinf2B addwaypoint [position player, 150];
wp1 setwaypointtype "GUARD";
wp1 setWaypointFormation "VEE";
hint "BAF Squad ready for combat"; 

I would like to replace the AT weapons for the BAF units to the US M136. I am using Pogoman awesome script that reloads the M136 & RPG 18 AI's magazines during the game. This allows the AT AI units to have better combat efficient in my opinion.

Thanks AVIBIRD,

---------- Post added at 18:16 ---------- Previous post was at 17:58 ----------

This was my last attempt.

removeAllWeapons this; this addWeapon "BAF_L85A2_UGL_ACOG "; this addMagazine "30Rnd_556x45_Stanag, 1Rnd_HE"; this addWeapon "M9SD"; this addMagazine "15Rnd_9x19_M9SD"; this addWeapon "M136"; this addMagazine "M136"; this addWeapon "NVGoggles"; this addWeapon "Binocular_Vector";

This works in the editor ie unit inti box but I don't know who to insert the code into the above script I know I am missing something like this within the code , () [] ; LOL. This is the stuff that can make you go nuts.

Edited by AVIBIRD 1

Share this post


Link to post
Share on other sites

the way i would do it would be to removeall weapons from units in the group, using foreach. then add he guns the same way. you will have to specify the unit name if you are being specific...

infBAF1 addweapon blah.

Share this post


Link to post
Share on other sites

Where in the code to I insert the remove and add. I am a little lost where to insert. I tryed a few areas but the SQF did not complete the initation of the script.

Share this post


Link to post
Share on other sites

{removeAllWeapons _x } foreach units Groupinf2B;

add in after set skill, then try a sleep of 0.5, then add the weapons from then onwards.

also [] exec "AISUPPORT\menu\ci_menu2_close.sqf"; shouldnt it be [] execVM "AISUPPORT\menu\ci_menu2_close.sqf"; ??

possibly halting there

Share this post


Link to post
Share on other sites

Thank you I will try that out but as soon as I can but the [] exec "AISUPPORT\menu\ci_menu2_close.sqf"; works fine in my mission!You call it by using a different menu. I don't know if that makes a differenace. I don't know what or why you are saying that lol still learning my way around coding lol. A lot of trial and error to get things to work right. I am almost done with my mission for relase(:

Share this post


Link to post
Share on other sites

exec is used for .sqs files, use execVM for .sqf.

Share this post


Link to post
Share on other sites

You could also spawn units like this:

Groupinf2B = CreateGroup WEST;

"BAF_Soldier_SL_DDPM" createUnit [position player, Groupinf2B, " removeAllWeapons this; this addWeapon 'M4A1' ", 0.6, "SERGEANT"];

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  

×