Jump to content
RyanTurner

Simple Init Spawning Player, Playable and AI Units

Recommended Posts

Hello, I was trying to understand why it's my code only spawn 3 of 4 units, while 1 of those it's a player and another it's a playable unit.

 

What I've working.

 

Have the players already insert in the mission.

Starting the mission, spawns me (SL), AI1 (TL) and AI2(HMG), but it doesn't spawn the 4th member.

I want the Player (SL) Playable (TL) AI1 (Corpsman) AI2 (HMG).

While giving the loadouts it stops at 

_sfbud2 = units TSG__sfPlayerTeam select 4; // Heavy Machine-Gunner

Since it can't detect the "4th" member

 

and this

//Init.sqf

skiptime -2.6;
//0 fadeSound 0;

TSG__sfPlayerTeam = [getMarkerPos "TSG_SfSpawner", west, ["B_Soldier_SL_F","B_soldier_TL_F","B_mediv_F","B_HeavyGunner_F"]] call BIS_fnc_spawnGroup;
{_x allowFleeing 0} forEach [TSG__sfPlayerTeam];
//FF module on player group
_module		= ["Init", [units TSG__sfPlayerTeam, true]] call BIS_fnc_moduleFriendlyFire;

selectPlayer leader TSG__sfPlayerTeam;
selectPlayer TSG_sfPartner
TSG__sfPlayerTeamSpeaker = TSG__sfPlayer;
TSG__sfPlayer setIdentity "TO_InfantryLeader";
TSG__sfPlayer setGroupID [localize "STR_A3_radio_a","GroupColor0"];
TSG__sfPlayer setDir 280;
TSG__sfPlayer setvariable ["bis_fnc_kbTellLocal_name", Localize "STR_A3_radio_a"];

_comeca = execVM "TSG_Sf_rearm.sqf";

 

//TSG_Sf_rearm.sqf

{
  removeAllWeapons _x;
  removeUniform _x;
  removeVest _x;
  removeBackpack _x;
  removeHeadgear _x;
  removeGoggles _x;
  _x removeItem "NVGoggles";
  _x unassignItem "NVGoggles";

} forEach units TSG__sfPlayerTeam;

_sf_sfPlayer  = units TSG__sfPlayerTeam select 1; // _sfPlayer
_sfPartner = units TSG__sfPlayerTeam select 2; // Partner
_sfbud1 = units TSG__sfPlayerTeam select 3; // Corspman
_sfbud2 = units TSG__sfPlayerTeam select 4; // Heavy Machine-Gunner

// _sfPlayer
comment "Add containers";
_sfPlayer setRank "SERGEANT";
_sfPlayer forceAddUniform "U_B_CombatUniform_mcam_vest";
_sfPlayer addItemToUniform "FirstAidKit";
for "_i" from 1 to 2 do {_sfPlayer addItemToUniform "30Rnd_65x39_caseless_mag";};
_sfPlayer addVest "V_PlateCarrierGL_rgr";
for "_i" from 1 to 2 do {_sfPlayer addItemToVest "16Rnd_9x21_Mag";};
for "_i" from 1 to 2 do {_sfPlayer addItemToVest "HandGrenade";};
for "_i" from 1 to 2 do {_sfPlayer addItemToVest "SmokeShell";};
for "_i" from 1 to 7 do {_sfPlayer addItemToVest "30Rnd_65x39_caseless_mag";};
for "_i" from 1 to 4 do {_sfPlayer addItemToVest "1Rnd_HE_Grenade_shell";};
_sfPlayer addHeadgear "H_HelmetB_light_grass";

comment "Add weapons";
_sfPlayer addWeapon "arifle_MX_GL_Black_F";
_sfPlayer addPrimaryWeaponItem "acc_pointer_IR";
_sfPlayer addPrimaryWeaponItem "optic_Hamr";
_sfPlayer addWeapon "hgun_P07_F";
_sfPlayer addWeapon "Binocular";

If someone can help me, thank you.

_RTURNER

Share this post


Link to post
Share on other sites

Any array starts at index 0. If you want the 1st element you refer to index 0 (array select 0). So, with 4 element arrays like your units, the last one, "B_HeavyGunner_F", will be selected by index 3 (array select 3).

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

×