Jump to content
Sign in to follow this  
clydefrog

Deleting vehicle crew after they leave a vehicle

Recommended Posts

Hi,

I know how to delete a vehicle and its crew together, but how do you delete the crew if they have left the vehicle? Basically I'm making a convoy script but if say a vehicle crashes and the crew get out, I'd like to delete that vehicle and the guys who got out of it so they aren't left on the map and counted as part of the convoy group. Any ideas?

Share this post


Link to post
Share on other sites

Hmm ok, but I'm not quite sure how I'd use that in the script, could you please give me an example if you know? It needs to be for the units of individual vehicles that have been spawned with BIS_fnc_spawnvehicle and named _veh1, _veh2 etc.

Share this post


Link to post
Share on other sites
_veh1 = [markerPos "spawn", 180, "B_Hunter_HMG_F", WEST] call bis_fnc_spawnvehicle;
_vehicle = _veh1 select 0;
_crew = _veh1 select 1;

waitUntil {{_x in _vehicle} count (_crew) == 0};

{deleteVehicle _x} forEach (_crew) + [_vehicle];

Share this post


Link to post
Share on other sites

Thanks cobra I'll try this soon. Can I also do it as an if () then {}; statement, e.g.

if({{_x in _vehicle} count (_crew) == 0}) then {{deleteVehicle _x} forEach (_crew) + [_vehicle]};

instead?

Share this post


Link to post
Share on other sites

Yes an if statement would work.

When using BIS_fnc_spawnVehicle

_this select 0 = the vehicle

_this select 1 = the crew

_this select 2 = the group

Share this post


Link to post
Share on other sites
Yes an if statement would work.

When using BIS_fnc_spawnVehicle

_this select 0 = the vehicle

_this select 1 = the crew

_this select 2 = the group

Thanks for the info, going to give it a try now.

---------- Post added at 23:18 ---------- Previous post was at 22:44 ----------

Ok that's actually not working, I have the following:

_v1 = [[_spawnPos select 0,_spawnPos select 1,1], _spawnDir, _vehClass1, _convoy] call BIS_fnc_spawnVehicle;

_veh1 = 	_v1 select 0;  		// name of vehicle spawned.
_veh1crew = 	_v1 select 1; 		// name vehicle crew

if ({{_x in _veh1} count (_veh1crew) == 0}) then {{deleteVehicle _x} forEach (_veh1crew) + [_veh1]};

Do you see any problem there?

Share this post


Link to post
Share on other sites

You have too many {}

if ({_x in _veh1} count (_veh1crew) == 0) then {{deleteVehicle _x} forEach (_veh1crew) + [_veh1]};

Share this post


Link to post
Share on other sites

Thanks again Sel, it's working now. I just thought though, is there also a way to remove one of the vehicles and it's crew from the group if the crew leave the vehicle, instead of deleting them? That way they could stay wherever they stopped and jumped out but they wouldn't count towards the group anymore meaning you wouldn't have to go around looking for them to kill the whole group. I'm just trying to think of and try a few possible ways of having this work before I decide on the best way.

And one other thing, say I named my group "convoygroup" and I had a trigger on the map with the condition: {alive _x} count units convoygroup == 0 to detect when the group is eliminated (as an example to trigger a task as succeeded), how could I stop that trigger from being activated when the script deletes the whole group after they arrive at the destination marker (in which case in this example the task would've been failed)?

Share this post


Link to post
Share on other sites

_v1 = [[_spawnPos select 0,_spawnPos select 1,1], _spawnDir, _vehClass1, _convoy] call BIS_fnc_spawnVehicle;
_vehicle = _v1 select 0;
_crew = _v1 select 1;

waitUntil {{_x in _vehicle} count (_crew) == 0};

{[_x] joinSilent grpNull} forEach _crew;

Edited by cobra4v320

Share this post


Link to post
Share on other sites

Thanks cobra, and I take it if I wanted to remove the vehicle from the group too (I guess I would still need to do that or would removing the crew from the group also remove the vehicle?) I would do this instead?:

{[_x] joinSilent grpNull} forEach (_crew) + [_vehicle]

Share this post


Link to post
Share on other sites

No, just the way I had it. If you want to delete the vehicle use deleteVehicle _vehicle, no need to remove it from the group.

Share this post


Link to post
Share on other sites
No, just the way I had it. If you want to delete the vehicle use deleteVehicle _vehicle, no need to remove it from the group.

So when a vehicle becomes empty is it no longer part of a group?

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  

×