Jump to content
wraith676

addGoggles script bugged or not working as intended?

Recommended Posts

Hello all. I have been trying to script some units to spawn on my character when i activate an addaction.

Here is the piece of code i was using to test this problem. 

 

_unit01 = group player createUnit ["B_Soldier_F", position player, [], 0.9, "FORM"];



comment "Remove existing items";
removeAllWeapons _unit01;
removeAllItems _unit01;
removeAllAssignedItems _unit01;
removeUniform _unit01;
removeVest _unit01;
removeBackpack _unit01;
removeHeadgear _unit01;
removeGoggles _unit01;

comment "Add containers";
_unit01 forceAddUniform "U_Competitor";
_unit01 addItemToUniform "FirstAidKit";
_unit01 addVest "V_Rangemaster_belt";
_unit01 addHeadgear "H_HelmetB";
_unit01 addGoggles "G_Balaclava_TI_G_tna_F";

comment "Add weapons";

comment "Add items";
_unit01 linkItem "ItemMap";
_unit01 linkItem "ItemCompass";
_unit01 linkItem "ItemWatch";
_unit01 linkItem "ItemRadio";

comment "Set identity";
_unit01 setFace "GreekHead_A3_03";
_unit01 setSpeaker "";

_unit01 addGoggles "G_Balaclava_TI_G_tna_F"; this particular line doesnt seem to work(The balaclava doesnt spawn on the unit.)

Im pretty sure this is a bug of some kind, can someone else test and see if you can duplicate this or let me know how i can fix it so that i can use the item on my spawned in units.

Thanks.

Share this post


Link to post
Share on other sites

Probably it just has to do with the config of the unit. Glasses are selected by an Eventhandler that's configured in the unit. They are not hardcoded into the gear of the unit, so they're added after creation of the unit. Your addGoggles-command may be executed before the configured goggle is selected, thus overwriting your addGoggles command.

You could try to add the goggles last in your script (although that probably won't fix that), or add a sleep 0.5; or a waitUntil or a cba_fnc_waitUntilAndExecute or something like that to check for that. Alternatively you could try to disable randomization for that unit, with: _unit01 setVariable ["BIS_enableRandomization", false];

  • Like 1

Share this post


Link to post
Share on other sites

What @Belbo said, disable the randomization to prevent this from happening.

 

On a sidenote, skip all those lines of removeItem, addMagazine etc and use getUnitLoadout and setUnitLoadout instead.

Hop in the editor, change a units loadout to your hearts content, then simply use the "copyToClipboard str getUnitLoadout YourUnitName" command and store the units loadout in an array for later use.

 

Using those two commands your snippet above would boil down to this:

_unit01Loadout = [[],[],[],["U_Competitor",[["FirstAidKit",1]]],["V_Rangemaster_belt",[]],[],"H_HelmetB","G_Balaclava_TI_G_tna_F",[],["ItemMap","","ItemRadio","ItemCompass","ItemWatch",""]];
_unit01 setUnitLoadout _unit01Loadout;

 

Cheers

  • Like 2

Share this post


Link to post
Share on other sites

Thanks to both of you.

I cant wait to get home this evening and have a play to see if i can get this working. 

Much appreciated :D

Share this post


Link to post
Share on other sites

Double post

Edited by wraith676
Double post

Share this post


Link to post
Share on other sites

Hello,

Just to let you guys know the sleep thing worked like a treat. However i also played around with your suggestion @Grumpy Old Man and tried the setUnitLoadout and it also works quite well.

Thanks again.:D

  • Like 1

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

×