Jump to content
Sign in to follow this  
avibird 1

How do you add something to a objects init box when spawning from a SQF

Recommended Posts

How would you write the code lines to add something to a unit/object init box when spawning them in using a SQF. Very simple when using the editor but from a SQF I have no clue!

for example

man1 = GroupA createUnit ["US_Soldier_SL_EP1", _pos, [], 0, "FORM"];

man2 = GroupA createUnit ["US_Soldier_TL_EP1", _pos, [], 0, "FORM"];

man3 = GroupA createUnit ["US_Soldier_Marksman_EP1", _pos, [], 0, "FORM"];

If I want to add a weapon, addaction what ever how would I insert the code into the above for the SL.

Share this post


Link to post
Share on other sites

setVehicleInit

processInitCommands

man1 = GroupA createUnit ["US_Soldier_SL_EP1", _pos, [], 0, "FORM"];
man1 setVehicleInit "this allowDamage false; removeAllWeapons this;";
processInitCommands;

However, in the case of your example, you can just use addWeapon/addAction or whatever to the unit directly:

man1 = GroupA createUnit ["US_Soldier_SL_EP1", _pos, [], 0, "FORM"];
man1 allowDamage false;
removeAllWeapons man1;

setVehicleInit comes in handy when you are respawning a unit with code in its init field - vehicles at your base, for example (see Tophe's very popular Simple Vehicle Respawn Script).

Honestly, I am not sure why one would use setVehicleInit when spawning units directly (the command is a gaping security issue, and was removed from Arma 3 during the alpha), but that's due to my very simple grasp of Arma scripting in general. Hoping someone can chime in on that!

Share this post


Link to post
Share on other sites

You wouldn't necessarily need to you could just do it within the script using the local variable so.

man1 = GroupA createUnit ["US_Soldier_SL_EP1", _pos, [], 0, "FORM"];

man1 addWeapon "classname"

Myaction = man1 addAction "add action

or if you really want to use Init field you can use

man1 setVehicleInit "this addWeapon ""classname"";";

processInitCommands;

I don't really use init commands when creating a unit as they sometimes won't work for me.

Share this post


Link to post
Share on other sites

hey Harzach and Blueblood both did not work.

this is the code lines I am working on

FBPflag = createVehicle ["FlagCarrierUSArmy_EP1", _pos, [], 0, "FORM"];

FBPflag setPosATL [(getPos FBP select 0) + (6 * sin(360)), (getPos FBP select 1) + (6 * cos(360)), 0];

this setVariable "R3F_LOG_disabled",true ; I am trying to add this to the flag so it can not be moved

The flag is at a Defensive fallback Position that a player can call to be build during the mission. The flag is also a base menu using the addaction command

like this:

1 = FBPD addaction ["Disband Fallback", "AVI\support\Fallbackdone.sqf"];

2. ect

3. ect

This code works fine /// this setVariable "R3F_LOG_disabled",true ; /// if I put it in the object init box from the editor but the whole fallback position is dynamic and can be called at any location on the map the player needs it.

Any help would be great Avibird.

---------- Post added at 05:39 ---------- Previous post was at 04:57 ----------

I found a way to stop the flag from being pick up using the [R3F] Artillery and Logistic script. There is a section that allows you to edit items but that means all items of that class can not be used by the script. This code //this setVariable "R3F_LOG_disabled",true ;// if put in the init box from the editor will only stop that object from using the script. I would still like to use the code in init box of units/objects that are spawned in during the mission using a SQF. I need a few other things to work from items being spawn from SQF's in my mission. Avibird

Share this post


Link to post
Share on other sites
This code works fine /// this setVariable "R3F_LOG_disabled",true ; /// if I put it in the object init box from the editor but the whole fallback position is dynamic and can be called at any location on the map the player needs it.

setVariable uses the format:

objectName setVariable [name, value, (public)]

so I don't see how that could work. It should be:

this setVariable ["R3F_LOG_disabled",true,true];

The script version should be:

FBPflag = createVehicle ["FlagCarrierUSArmy_EP1", _pos, [], 0, "FORM"];
FBPflag setPosATL [(getPos FBP select 0) + (6 * sin(360)), (getPos FBP select 1) + (6 * cos(360)), 0];
FBPflag setVariable ["R3F_LOG_disabled",true,true];

Share this post


Link to post
Share on other sites

thanks I will check it out and let you know.

How would you insert this code _null = [this,"fullAuto"] execVM "medicAuto.sqf";

This is a really great script called Automated Medic by demonized. execute: place in initline of medic/s. works great from the editor but I am making my mission using SQF's.

if my SQF looks like this:

_pos = [(getPosATL Player select 0) + (500 * sin(180)), (getPosATL Player select 1) + (500 * cos(180)), 0];

GroupA = CreateGroup WEST;

A1 = GroupA createUnit ["US_Soldier_SL_EP1", _pos, [], 0, "FORM"];

A2 = GroupA createUnit ["US_Soldier_TL_EP1", _pos, [], 0, "FORM"];

A3 = GroupA createUnit ["US_Soldier_Marksman_EP1", _pos, [], 0, "FORM"];

A4 = GroupA createUnit ["US_Soldier_GL_EP1", _pos, [], 0, "FORM"];

A5 = GroupA createUnit ["US_Soldier_GL_EP1", _pos, [], 0, "FORM"];

A6 = GroupA createUnit ["US_Soldier_AR_EP1", _pos, [], 0, "FORM"];

A7 = GroupA createUnit ["US_Soldier_AR_EP1", _pos, [], 0, "FORM"];

A8 = GroupA createUnit ["US_Soldier_LAT_EP1", _pos, [], 0, "FORM"];

A9 = GroupA createUnit ["US_Soldier_LAT_EP1", _pos, [], 0, "FORM"];

A10 = GroupA createUnit ["US_Soldier_AT_EP1", _pos, [], 0, "FORM"];

A11 = GroupA createUnit ["US_Soldier_AT_EP1", _pos, [], 0, "FORM"];

A12 = GroupA createUnit ["US_Soldier_HAT_EP1", _pos, [], 0, "FORM"];

A13 = GroupA createUnit ["US_Soldier_AA_EP1", _pos, [], 0, "FORM"];

A14 = GroupA createUnit ["US_Soldier_Medic_EP1", _pos, [], 0, "FORM"];

A15 = GroupA createUnit ["US_Soldier_Medic_EP1", _pos, [], 0, "FORM"];

A1 = leader GroupA;

How would I put the medic script into the two medics in GroupA

Share this post


Link to post
Share on other sites
_null = [A14,"fullAuto"] execVM "medicAuto.sqf";
_null = [A15,"fullAuto"] execVM "medicAuto.sqf";

Share this post


Link to post
Share on other sites

What is wrong with the codes! I know it works in the editor using this in the code then the man1

_pos = [(getPosATL Player select 0) + (500 * sin(180)), (getPosATL Player select 1) + (500 * cos(180)), 0];

GroupA = CreateGroup WEST;

man1 = GroupA createUnit ["US_Soldier_SL_EP1", _pos, [], 0, "FORM"];

man1 allowDamage false;

removeAllWeapons man1;

man1 addWeapon "BAF_L85A2_UGL_ACOG ";

man1 addMagazine "30Rnd_556x45_Stanag, 1Rnd_HE";

man1 addbackpack [“US_Backpack_AT_EP1â€]

(unitBackpack man1) addMagazineCargo ["Pipebomb",3];

Share this post


Link to post
Share on other sites

AVIBIRD1, have you tried the "older" createUnit, which allows for init command?

I personally wouldn't use the setVehicleInit & processInitCommands... I've read several posts in these forums why NOT to use them.

the init part is a string, so remember to use "double quotes"... ie:

A14 = "US_Soldier_Medic_EP1" createUnit [_pos, GroupA,"[this,'fullAuto'] execVM 'medicAuto.sqf'"];

Share this post


Link to post
Share on other sites

I got the execVM 'medicAuto.sqf working fine with the _null = [A14,"fullAuto"] execVM "medicAuto.sqf";

FBPflag setVariable ["R3F_LOG_disabled",true,true]; I can't get it to work but the R3F script has a section you can just // the item (flag) and the script stops working for that item.

I can't add weapons to my squads I want to customize unit gear for multiple squads that can be called in during the game using SQF.

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  

×