Jump to content
FunnyCookieEver

Condition to check if vehicle of side/player is in radius

Recommended Posts

So as the title says, I've an issue with this condition

(({_x distance _sectorController < ARES_activationDistance && side _x == west } count vehicles) > 0)

I'm writing a check for player in area of an sector to activate it (spawn patrols, units etc.) basically all town and stuff would have it.

Check for player as a unit on ground works fine on hosted and dedicated, but problem comes if player is in vehicle.

So it works on hosted (other players can also activate them, tested) but doesn't on dedicated for some reason.

Here is whole code section with this check.
Need help 😞

if (((({_x distance _sectorController < ARES_activationDistance} count allPlayers) > 0) || (({_x distance _sectorController < ARES_activationDistance && side _x == west } count vehicles) > 0) ) && (_sectorController getVariable "ARES_sectorActive" != true)) then {
	_sectorController setVariable ["ARES_sectorActive", true, true];
	switch (_sectorController getVariable "ARES_sectorController") do {
		case west: { [west, _sectorController, 1, false] call ARES_fnc_populateArea; };
		...
		default {  };
	};
};

Share this post


Link to post
Share on other sites

(({_x distance _sectorController < ARES_activationDistance && side _x == west } count vehicles) > 0)  works on vehicles only (not infantry).

 

Perhaps, you should work on:

(({_x distance _sectorController < ARES_activationDistance && side _x == west } count allPlayers) > 0)

If you need to check players in vehicles only, just add a condition:

(({_x distance _sectorController < ARES_activationDistance && side _x == west && !isnull objectParent _x } count allPlayers) > 0)

 

 

 

_sectorController getVariable "ARES_sectorActive" != true    is not fine syntax. Replace by:

!(_sectorController getVariable "ARES_sectorActive")

or even by:

!(_sectorController getVariable ["ARES_sectorActive",false])   // false by default avoids error when this variable is not yet defined. Doesn't change the result

 

You can also:

private _controlled = _sectorController getVariable ["ARES_sectorActive",false];

then check :  _controlled ... or !_controlled (what you need)

 

Edited by pierremgi
UNCLEAR ON FIRST ATTEMPT
  • Confused 1

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

×