Jump to content
Sign in to follow this  
hogmason

fill empty cargo seats

Recommended Posts

righto so i am spawning vehicles in random spots now that all works fine but i have attempted to create units in all the empty seats in the vehicles but it is not working i gwt no rpt error but the vehicles are empty.

this is all the code the fill seats part is in red

//create the vehicles
/////////////////////
waituntil {!isnil "bis_fnc_init"};

_veh_patrol_grp = createGroup east;
_veh_patrol_center = createCenter east;

   MARKER_array = [];

        for "_i" from 0 to 100 do
        {
		_gamelogic = center;
	      _towns1 = nearestLocations [getPosATL _gamelogic, ["NameVillage","NameCity","NameCityCapital"], 25000];
	       _RandomPosition3 = position (_towns1 select (floor (random (count _towns1))));
	        _marker = createmarkerLocal [format ["mrk%1",random 999999], _RandomPosition3];
                MARKER_array set[(count MARKER_array), _marker];
	    };

   for "_i" from 0 to 10 do 
   {
     _veh_patrol_type = ["T72_TK_EP1","T55_TK_EP1","V3S_TK_EP1","V3S_TK_EP1","V3S_TK_EP1","V3S_Open_TK_EP1","V3S_Open_TK_EP1","V3S_Open_TK_EP1","V3S_Open_TK_EP1","V3S_TK_EP1","BRDM2_ATGM_TK_EP1","M113_TK_EP1","UAZ_AGS30_TK_EP1","LandRover_MG_TK_EP1","UAZ_AGS30_TK_EP1","BRDM2_ATGM_TK_EP1","LandRover_SPG9_TK_EP1"] call BIS_fnc_selectRandom;
      _veh_patrol_gamelogic = center;
    _veh_patrol_towns = nearestLocations [getPosATL _veh_patrol_gamelogic, ["Hill","ViewPoint","StrongpointArea"], 25000]; // or   "NameVillage","NameCity","NameCityCapital"
     _veh_patrol_RandomPosition = position (_veh_patrol_towns select (floor (random (count _veh_patrol_towns))));

	    _veh_patrol_vehicle = createVehicle [_veh_patrol_type, _veh_patrol_RandomPosition, [], 0, "NONE"];			
            _veh_patrol_vehicle setDir random 290;
		 //_spawned = (_veh_patrol_vehicle select 0);
		  //_veh_patrol_vehicle setVehicleInit "[""killed"",{null = this execVM 'common\newAA.sqf';}]";
              //processInitCommands;

[color="#FF0000"]	_cargoNum = _veh_patrol_vehicle emptyPositions "cargo";
if (_cargoNum > 0) then 
{
  _fillSlots = round (random _cargoNum);
   _pos = getPos _veh_patrol_vehicle;
    _locGr =  _pos findEmptyPosition [10, 100];
	 sleep .2;

	if (_locGr select 0 > 0)then 
	{
	   _cargo = [_locGr, _veh_patrol_grp , _cargoNum,[],[],[],[],[_fillSlots,.5]] call BIS_fnc_spawnGroup;
	    sleep .2;
		 {_x moveInCargo _veh_patrol_vehicle;} forEach units _cargo;
	};
};[/color]


            if (HOG_debug) then 
            {                 
	         [sgt,nil,rgroupChat,"Spawning Enemy Jet + Debug ON."] call RE; 
                 sleep 0.2;				
                  [_veh_patrol_vehicle,"patrol","ColorRed","mil_dot"] spawn TOD_debug_mkrs_fnc;
               };				 
   };	  






any one know how to solve fix cheers.

Share this post


Link to post
Share on other sites

Not sure, not tested, but maybe this is about that:

assignAsCargo

(applied to each spawned unit before moveInCargo).

Cargo units are spawned, but stays outside, or aren't spawned at all?

In one of my functions such code gives needed result:

		_frPos = _veh emptyPositions "cargo";
	if (_cargoN < 0) then {_cargoN = _frPos};//_cargoN - number of cargo units to spawn

	if (_frPos >= _cargoN) then 
		{
		_sets = ["INF",_side] call RYD_Pool;//choosing unit classes to spawn by special function, part of my custom spawner (BIS_fnc_spawnGroup should work fine instead, I guess)
		_Cgrp = [_sets,_side,(position _veh),_cargoN,"NONE"] call RYD_SummonU; //another part of my custom group spawner spawns units of chosen classes
		_ldr = leader _Cgrp;//this and next lines needed, as used spawner always creates new group for spawned units
		_uCg = units _Cgrp;
		_uCg joinSilent _SummonedGrp;//_SummonedGrp - vehicle crew group
		_SummonedGrp selectLeader _ldr;

			{
			_x assignAsCargo _veh;
			_x moveInCargo _veh
			} 
		foreach _uCg
		};

Share this post


Link to post
Share on other sites

Do all of the vehicles in your array you are selecting from have cargo positions? T72, T55... Don't use these much so I don't know

You are using the createVehicle array, and not spawn vehicle... Do you have driver's for these empty vehicles?

Your spawn group code, where you have _veh_patrol_grp, points to a group. This needs to be a side.

This cargo code, I have seen in DTM's convoy script(but adjusted to my taste). I removed the randoms and probabilities and just filled them up completely

I can help you more once I get home and in front of my own computer.

Edited by panther42

Share this post


Link to post
Share on other sites

Yeah dtm thats were i got it from also. cheers mate ive given up on it after spending the last 2 days onit constantly lol. Yeah the tanks dont have empty seats mainly the jeeps and transport trucks is what i am after. Ill place my full code here in the next hour mate its changed abit. thanks heaps

---------- Post added at 08:30 ---------- Previous post was at 08:25 ----------

this is the code


//create the vehicles
/////////////////////
waituntil {!isnil "bis_fnc_init"};
sleep 10;
_veh_patrol_center = createCenter east;
_veh_patrol_grp = createGroup east;


   MARKER_array = [];

        for "_i" from 0 to 100 do
        {
		_gamelogic = center;
	      _towns1 = nearestLocations [getPosATL _gamelogic, ["NameVillage","NameCity","NameCityCapital"], 25000];
	       _RandomPosition3 = position (_towns1 select (floor (random (count _towns1))));
	        _marker = createmarkerLocal [format ["mrk%1",random 999999], _RandomPosition3];
                MARKER_array set[(count MARKER_array), _marker];
	    };

   for "_i" from 0 to 10 do 
   {
     _veh_patrol_type = ["T72_TK_EP1","T55_TK_EP1","V3S_TK_EP1","V3S_TK_EP1","V3S_TK_EP1","V3S_Open_TK_EP1","V3S_Open_TK_EP1","V3S_Open_TK_EP1","V3S_Open_TK_EP1","V3S_TK_EP1","BRDM2_ATGM_TK_EP1","M113_TK_EP1","UAZ_AGS30_TK_EP1","LandRover_MG_TK_EP1","UAZ_AGS30_TK_EP1","BRDM2_ATGM_TK_EP1","LandRover_SPG9_TK_EP1"] call BIS_fnc_selectRandom;
      _veh_patrol_gamelogic = center;
    _veh_patrol_towns = nearestLocations [getPosATL _veh_patrol_gamelogic, ["Hill","ViewPoint","StrongpointArea"], 25000]; // or   "NameVillage","NameCity","NameCityCapital"
     _veh_patrol_RandomPosition = position (_veh_patrol_towns select (floor (random (count _veh_patrol_towns))));

	 _spawn = [(_veh_patrol_RandomPosition), _veh_patrol_type, _veh_patrol_grp] call BIS_fnc_spawnVehicle;
	    //_veh_patrol_vehicle = createVehicle [_veh_patrol_type, _veh_patrol_RandomPosition, [], 0, "NONE"];			
            _veh_patrol_vehicle setDir random 290;
		 _spawned = (_spawn select 1);
		  //_veh_patrol_vehicle setVehicleInit "[""killed"",{null = this execVM 'common\newAA.sqf';}]";
              //processInitCommands;

_cargoNum = _spawned emptyPositions "cargo";
if (_cargoNum > 0) then 
{
  _fillSlots = round (random _cargoNum);
   _pos =  _veh_patrol_RandomPosition;
    _locGr =  _pos findEmptyPosition [10, 100];
	 sleep .2;

	if (_locGr select 0 > 0)then 
	{
	   _cargo = [_locGr, _veh_patrol_grp , _cargoNum,[],[],[],[],[_fillSlots,.5]] call BIS_fnc_spawnGroup;
	    sleep .2;
		 {_x moveInCargo _spawned;} forEach units _cargo;
	};
};

   };	

Share this post


Link to post
Share on other sites

Ok, hogmason. Here is how I do this in my edited DTM convoy script. I wanted the freedom of selecting which type of units made up the group which was placed in the cargo slots. I also wanted the cargo positions "filled".

Example:

     _cargoNum = _spawned emptyPositions "cargo";
		  if (_cargoNum > 0) then {
				_pos = getpos _position;
				_locGr =  _pos findEmptyPosition [10, 100];
				_troopArray = ["US_Soldier_SL_EP1","US_Soldier_B_EP1","US_Soldier_LAT_EP1","US_Soldier_B_EP1","US_Soldier_Marksman_EP1","US_Soldier_GL_EP1","US_Soldier_AR_EP1","US_Soldier_AAR_EP1","US_Soldier_Medic_EP1"];
				_grp = createGroup _side;
				sleep .2;
					if (_locGr select 0 > 0)then {
						for "_i" from 1 to _cargoNum do 
						{
							_troops = _troopArray call BIS_fnc_selectRandom;
							_cargo = _grp createUnit [_troops, _locGr, [], 0, "FORM"];
							//sleep .2;
							{_x assignAsCargo _spawned; _x moveInCargo _spawned;} forEach units _cargo;
						}; 
					}; 
			};

Here is how you can change yours to work possibly. Take note of the highlights in red:

    for "_i" from 0 to 10 do 
   {
     _veh_patrol_type = ["T72_TK_EP1","T55_TK_EP1","V3S_TK_EP1","V3S_TK_EP1","V3S_TK_EP1","V3S_Open_TK_EP1","V3S_Open_TK_EP1","V3S_Open_TK_EP1","V3S_Open_TK_EP1","V3S_TK_EP1","BRDM2_ATGM_TK_EP1","M113_TK_EP1","UAZ_AGS30_TK_EP1","LandRover_MG_TK_EP1","UAZ_AGS30_TK_EP1","BRDM2_ATGM_TK_EP1","LandRover_SPG9_TK_EP1"] call BIS_fnc_selectRandom;
      _veh_patrol_gamelogic = center;
    _veh_patrol_towns = nearestLocations [getPosATL _veh_patrol_gamelogic, ["Hill","ViewPoint","StrongpointArea"], 25000]; // or   "NameVillage","NameCity","NameCityCapital"
     _veh_patrol_RandomPosition = position (_veh_patrol_towns select (floor (random (count _veh_patrol_towns))));

	 _spawn = [(_veh_patrol_RandomPosition), [color="#FF0000"]random 290[/color], _veh_patrol_type, _veh_patrol_grp] call BIS_fnc_spawnVehicle;
	    //_veh_patrol_vehicle = createVehicle [_veh_patrol_type, _veh_patrol_RandomPosition, [], 0, "NONE"];
            [color="#FF0000"]_veh_patrol_vehicle = (_spawn select 0);[/color]			
            //_veh_patrol_vehicle setDir random 290;
		 //_spawned = (_spawn select 1);
		  //_veh_patrol_vehicle setVehicleInit "[""killed"",{null = this execVM 'common\newAA.sqf';}]";
              //processInitCommands;

_cargoNum = [color="#FF0000"]_veh_patrol_vehicle[/color] emptyPositions "cargo";
if (_cargoNum > 0) then 
{
  _fillSlots = round (random _cargoNum);
   _pos =  _veh_patrol_RandomPosition;
    _locGr =  _pos findEmptyPosition [10, 100];
	 sleep .2;

	if (_locGr select 0 > 0)then 
	{
	   _cargo = [_locGr, [color="#FF0000"]East[/color], _cargoNum,[],[],[],[],[_fillSlots,.5]] call BIS_fnc_spawnGroup;
	    sleep .2;
		 {_x moveInCargo [color="#FF0000"]_veh_patrol_vehicle[/color];} forEach units _cargo;
	};
};

   };

You can change side from East to whatever SIDE you want, or try using the same approach I did.

Let me know if this helped out.

Edited by panther42

Share this post


Link to post
Share on other sites

man once i recover from my daddy nap lmao i am going to use it that is bloody awsome mate you are a legend thank you ill let you know how i go ;) :yay:

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  

×