Jump to content
Sign in to follow this  
SaintPier

Wich units are in vehicle

Recommended Posts

Hi,

I have a plane that starts flying.

How can i get the array of units inside the plane?

Thanks,

SaintPier

Share this post


Link to post
Share on other sites

crew name_of_vehicle

you have also commands like driver name_of_vehicle, gunner, commander which maybe helpful when trying to get array of units who are just sitting in the back of plane.

for planes it should be enough

_cargo = (crew name_of_vehicle) - [driver name_of_vehicle,gunner name_of_vehicle]

Share this post


Link to post
Share on other sites
crew name_of_vehicle

you have also commands like driver name_of_vehicle, gunner, commander which maybe helpful when trying to get array of units who are just sitting in the back of plane.

for planes it should be enough

_cargo = (crew name_of_vehicle) - [driver name_of_vehicle,gunner name_of_vehicle]

Thanks again Reyhard.

Things can be sooooo easy right ?

Can you tell me also how to fill a flying plane with units?

I have found this c-130 and want to stuff as many units in as possible.

At a waypoint i want them to jump out. For that i have a script, but how to get the unit in a vehicle wich starts flying?

THX ;-)

Share this post


Link to post
Share on other sites

{_x moveincargo name_of_plane}foreach units group this - write this in init of group leader. This will put all units into plane. Be careful with that - if you will write this in any non-local space units will not get in (this is local command).

Share this post


Link to post
Share on other sites
{_x moveincargo name_of_plane}foreach units group this - write this in init of group leader. This will put all units into plane. Be careful with that - if you will write this in any non-local space units will not get in (this is local command).

With non-local space you mean network game?

If i write the script in the Init.sqs, will it work on all computers?

Share this post


Link to post
Share on other sites

yes - non-local space maybe script, that runs on client machines that are not servers.

But, I forget to mention about another thing, if leader of certain group is player (non-server client), then, if you would wrote that script in his init line, all AI units, that he has under his command, would not get in plane. So units that are local to player can be but to vehicles that are also local to him, but if vehicle is not local, then nothing will happen (you read about on biwiki, I'm bit tired right, so if it's not clear enough, I would reply tomorrow).

Share this post


Link to post
Share on other sites

here's a recent scriupt I wrote for making a team of spetsnaz and putting them in 2 APC's and 2 trucks - some of the syntax might be informative - it took me DAYS to get the cargo function to work and it came down to locations of spawn of unit and time delay between commands so far as i could see:

_pos1 = [5446.5645,8483.2402,0];
_pos2 = [5450.9009,8470.9336,0];
_pos3 = [5454.4937,8460.6992,0];
_pos4 = [5459.6235,8446.2354,0];

_pos5 = [((_pos1 select 0) + random 5),((_pos1 select 1)+random 5),(_pos1 select 2)];
_pos6 = [((_pos2 select 0) + random 5),((_pos2 select 1)+random 5),(_pos2 select 2)];
_pos7 = [((_pos3 select 0) + random 5),((_pos3 select 1)+random 5),(_pos3 select 2)];
_pos8 = [((_pos4 select 0) + random 5),((_pos4 select 1)+random 5),(_pos4 select 2)];

_pos9 = [((_pos1 select 0) + random 5),((_pos1 select 1)+random 5),(_pos1 select 2)];
_pos10 = [((_pos2 select 0) + random 5),((_pos2 select 1)+random 5),(_pos2 select 2)];
_pos11 = [((_pos3 select 0) + random 5),((_pos3 select 1)+random 5),(_pos3 select 2)];
_pos12 = [((_pos4 select 0) + random 5),((_pos4 select 1)+random 5),(_pos4 select 2)];

_targblue = getmarkerpos "markerlkwwest"; 
hint "ambo";
sleep 2;
if(round (random 1) == 1) then {_targblue = [4679,10452,0]; hint "airfield"};
sleep 2;

_spetz = createGroup (east);
	_allvecsNG = ["Ural_INS"];
	_allvecsG = ["GAZ_Vodnik_HMG","BTR90","BMP3","GAZ_Vodnik","BTR90_HQ","BMP2_INS","UAZ_MG_INS"];
//"Pickup_PK_INS","Ural_ZU23_INS"
	_maxG = (count _allvecsG)-1;
	_maxNG = (count _allvecsNG)-1;
	_heli = createVehicle [_allvecsG select (round random _maxG), _pos1, [], 0, "NONE"];[_heli] call BIS_EVO_Lock;Sleep BIS_EVO_GlobalSleep;
_spawne = [_heli] spawn {[_this select 0] call BIS_EVO_idelSVEC};
	_heli1 = createVehicle [_allvecsG select (round random _maxG), _pos2, [], 0, "NONE"];[_heli1] call BIS_EVO_Lock;Sleep BIS_EVO_GlobalSleep;
_spawne = [_heli1] spawn {[_this select 0] call BIS_EVO_idelSVEC};
	_heli2 = createVehicle [_allvecsNG select (round random _maxNG), _pos3, [], 0, "NONE"];[_heli2] call BIS_EVO_Lock;Sleep BIS_EVO_GlobalSleep;
_spawne = [_heli2] spawn {[_this select 0] call BIS_EVO_idelSVEC};
	_heli3 = createVehicle [_allvecsNG select (round random _maxNG), _pos4, [], 0, "NONE"];[_heli3] call BIS_EVO_Lock;Sleep BIS_EVO_GlobalSleep;
_spawne = [_heli3] spawn {[_this select 0] call BIS_EVO_idelSVEC};
_heli setdir 340;
_heli1 setdir 340;
_heli2 setdir 340;
_heli3 setdir 340;

_heli engineon true;
_heli1 engineon true;
_heli2 engineon true;
_heli3 engineon true;

//making infantry crews

_allunitsP = ["RU_Soldier_Pilot","RU_Soldier_Officer","RU_Soldier_Crew"];
//,"RUS_Commander"];
//
_max = (count _allunitsP)-1;

_allunitsP select (round random _max) createUnit [_pos5, _spetz];Sleep BIS_EVO_GlobalSleep;
sleep 0.2;
_allunitsP select (round random _max) createUnit [_pos6, _spetz];Sleep BIS_EVO_GlobalSleep;
sleep 0.2;
_allunitsP select (round random _max) createUnit [_pos7, _spetz];Sleep BIS_EVO_GlobalSleep;
sleep 0.2;
_allunitsP select (round random _max) createUnit [_pos8, _spetz];Sleep BIS_EVO_GlobalSleep;
sleep 0.2;
_allunitsP select (round random _max) createUnit [_pos9, _spetz];Sleep BIS_EVO_GlobalSleep;
sleep 0.2;
_allunitsP select (round random _max) createUnit [_pos10, _spetz];Sleep BIS_EVO_GlobalSleep;
sleep 0.2;

//hint format["6 Officer count %1",(count units _spetz)];

(units _spetz select 0) moveInDriver _heli;
sleep 0.2;
(units _spetz select 1) moveInGunner _heli;
sleep 0.2;
(units _spetz select 2) moveInDriver _heli1;
sleep 0.2;
(units _spetz select 3) moveInGunner _heli1;
sleep 0.2;
(units _spetz select 4) moveInDriver _heli2;
sleep 0.2;
(units _spetz select 5) moveInDriver _heli3;

_allunits = ["RUS_Soldier_GL","RUS_Soldier_Marksman","RUS_Commander","RUS_Soldier1","RUS_Soldier2","RUS_Soldier3","RUS_Soldier_TL"];
_max = count _allunits;

_allunits select (round random (_max - 1)) createUnit [_pos5, _spetz];Sleep BIS_EVO_GlobalSleep;
_allunits select (round random (_max - 1)) createUnit [_pos6, _spetz];Sleep BIS_EVO_GlobalSleep;
_allunits select (round random (_max - 1)) createUnit [_pos7, _spetz];Sleep BIS_EVO_GlobalSleep;
_allunits select (round random (_max - 1)) createUnit [_pos8, _spetz];Sleep BIS_EVO_GlobalSleep;
_allunits select (round random (_max - 1)) createUnit [_pos9, _spetz];Sleep BIS_EVO_GlobalSleep;
_allunits select (round random (_max - 1)) createUnit [_pos10, _spetz];Sleep BIS_EVO_GlobalSleep;
_allunits select (round random (_max - 1)) createUnit [_pos11, _spetz];Sleep BIS_EVO_GlobalSleep;
_allunits select (round random (_max - 1)) createUnit [_pos12, _spetz];Sleep BIS_EVO_GlobalSleep;

(units _spetz select 6) moveInCargo _heli2;
sleep 0.2;
(units _spetz select 7) moveInCargo _heli2; 
sleep 0.2;
(units _spetz select 8) moveInCargo _heli2;
sleep 0.2;
(units _spetz select 9) moveInCargo _heli2; 
sleep 0.2;
(units _spetz select 10) moveInCargo _heli2; 
sleep 0.2;
(units _spetz select 11) moveInCargo _heli2; 
sleep 0.2;
(units _spetz select 12) moveInCargo _heli2; 
sleep 0.2;
(units _spetz select 13) moveInCargo _heli2; 

_allunits select (round random (_max - 1)) createUnit [_pos5, _spetz];Sleep BIS_EVO_GlobalSleep;
_allunits select (round random (_max - 1)) createUnit [_pos6, _spetz];Sleep BIS_EVO_GlobalSleep;
_allunits select (round random (_max - 1)) createUnit [_pos7, _spetz];Sleep BIS_EVO_GlobalSleep;
_allunits select (round random (_max - 1)) createUnit [_pos8, _spetz];Sleep BIS_EVO_GlobalSleep;
_allunits select (round random (_max - 1)) createUnit [_pos9, _spetz];Sleep BIS_EVO_GlobalSleep;
_allunits select (round random (_max - 1)) createUnit [_pos10, _spetz];Sleep BIS_EVO_GlobalSleep;
_allunits select (round random (_max - 1)) createUnit [_pos11, _spetz];Sleep BIS_EVO_GlobalSleep;
_allunits select (round random (_max - 1)) createUnit [_pos12, _spetz];Sleep BIS_EVO_GlobalSleep;

(units _spetz select 14) moveInCargo _heli3; 
sleep 0.2;
(units _spetz select 15) moveInCargo _heli3; 
sleep 0.2;
(units _spetz select 16) moveInCargo _heli3; 
sleep 0.2;
(units _spetz select 17) moveInCargo _heli3; 
sleep 0.2;
(units _spetz select 18) moveInCargo _heli3; 
sleep 0.2;
(units _spetz select 19) moveInCargo _heli3; 
sleep 0.2;
(units _spetz select 20) moveInCargo _heli3; 
sleep 0.2;
(units _spetz select 21) moveInCargo _heli3; 

{_x addEventHandler ["killed", {handle = [_this select 0] execVM "data\scripts\bury.sqf"}]} forEach (units _spetz);
_heli addEventHandler ["killed", {handle = [_this select 0] execVM "data\scripts\bury.sqf"}];
_heli1 addEventHandler ["killed", {handle = [_this select 0] execVM "data\scripts\bury.sqf"}];
_heli2 addEventHandler ["killed", {handle = [_this select 0] execVM "data\scripts\bury.sqf"}];
_heli3 addEventHandler ["killed", {handle = [_this select 0] execVM "data\scripts\bury.sqf"}];

_recy = [objnull,_spetz] execVM "data\scripts\grecycle.sqf";

_spetz setCombatMode "SAFE";

//hint format["spetsnaz embarked %1",(count units _spetz)];

[West,"HQ"] SideChat "Spetznaz assault imminent!";playSound "Incoming";

_spetz setFormation "COLUMN";
_spetz setSpeedMode "LIMITED";
_spetz setBehaviour "SAFE";
//_spetz setCurrentWaypoint [_spetz, _targblue];  //unsure

sleep 20;
_wp = _spetz addWaypoint [_targblue, 80];
[_spetz, 1] setWaypointType "HOLD";
waitUntil {(count units _spetz) < 1};
//hint format["Spetz killed %1",(count units _spetz)];
//waitUntil {_x not alive} forEach (units _spetz);

sleep 1.0;
[West,"HQ"] SideChat "Spetznaz assault defeated!";playSound "Goodjob";
sleep 2;
[] call _deletespetz;
sleep 300 + (round random 900);

Share this post


Link to post
Share on other sites

Thanks Eggbeast.

The 'sleep' command is new for me. Is that a newer version of OFP maybe?

The command i use is ~

Anyway...I have the creation of units working. The problem is tp get it working in MP. Halfway the mission, there is a timed event, wich works fine when i test the mission alone. But yesterday we tried the mission with 3 MP's and the timed trigger didn't work. The trigger sets a boolean on activation to TRUE. In the init.sqs i Publish that variable with 'PublicVariable "SecondAttack" '. This is what i think is happaning :

On the server the trigger activates. SecondAttack becomes true.

PublicVariable "SecondAttack" sends the variable over the network.

But Init.sqs is also running on the clients, so the clients also do a 'PublicVariable "SecondAttack" '. The the boolean is FALSE again, while it should be set to TRUE. And stay TRUE.

In other words : I have to check where the script is running before publishing the variable. I have read something about IsServer, but can't find it in the editor i am using. Probably my OFP 1.96 version is to old.

grtzz

SaintPier

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  

×