Jump to content
Sign in to follow this  
TheGeneral2899

[SOLVED] Check if vehicle driver is dead OR vehicle is empty

Recommended Posts

I've searched on the forums and have tried several solutions with no avail.  Have tried the fullCrew, count, !alive driver etc.

 

Here is the code used to spawn in the vehicle / crew:

// SPAWNS VEHICLE IN AND SETS ITS DIRECTION
// CHANGE TO HUMMER MAYBE?
_veh = "B_Quadbike_01_F" createVehicle getMarkerPos "weaponObjStart"; 
createVehicleCrew _veh;
_dirVeh = markerDir "weaponObjStart";
_veh setDir _dirVeh;

// SETS GROUP OF THE DRIVER
_vehgrp = group driver _veh;

Here is the if dead check (I would also be totally cool with checking if the driver is dead or the vehicle has been abandoned).  Its an AI controlled vehicle and want to know if the players have disabled the wheels, thus forcing the AI to get out or if they just flat out shoot the guy.

 

c

if (count (fullCrew [_veh, "driver"]) == 0) then {
	//"vehObjective" setMarkerPos getPos debug;
	hint parseText _gearVehicleEndText;
};

Any help would be appreciated.   Can't seem to find a decent way to do this (that works).

 

Thanks!

Share this post


Link to post
Share on other sites

Try:

if ((count crew car1 < 1) || (!alive (driver (vehicle player)))) then
{
	// code...
};

Assuming the vehicle is named car1.

Not tested!

 

EDIT: I don't think crew will work for UAVs and UTVs. You shouldn't need to count the crew anyway but rather, is anyone connected?

Share this post


Link to post
Share on other sites

Afraid neither of those work.  This is such a simple idea to check yet somehow not working no matter what method I'm using.

Share this post


Link to post
Share on other sites

Why don't you use simple:

!alive driver _veh

where _veh can be any vehicle. If empty, it returns true as well.

 

Share this post


Link to post
Share on other sites

Yea I basically overcomplicated the whole thing.  Here is the solution:

 

// SPAWNS VEHICLE IN AND SETS ITS DIRECTION
gearVeh = "rhsusf_m1025_d" createVehicle getMarkerPos "weaponObjStart"; 
gearDriver moveInDriver gearVeh;
_dirVeh = markerDir "weaponObjStart";
gearVeh setDir _dirVeh;

// SPAWNS VEHICLE DRIVER WITH NAME "gearDriver"
_gearGroup = Creategroup WEST;
"B_RangeMaster_F" createUnit [getMarkerPos "weaponObjStart", _gearGroup, "gearDriver = this"];

Here is the check:

 

// Notification of mission ended
	if (!alive gearDriver) then {
		// CODE
	};

 

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  

×