Jump to content
Sign in to follow this  
LSValmont

Spotter script (Reworked!) Look at last post!

Recommended Posts

Hello Guys, after a long time not playing one of my missions I decided to upgrade it only to find that this Spotter script is showing errors it did not before:

Spoiler

 


if (!isServer) exitWith {};
_spotter = [_this, 0, objNull] call bis_fnc_param;
if (!local _spotter) exitWith {};
while {alive _spotter} do {
	waitUntil {sleep 1; _spotter in MissionSquad};
	hint format["As %1 (Spotter) joins the squad, Posible contacts positions in a 100 mtr. radius will be updated on map every 10 seconds",name _spotter];
	while {sleep 1; _spotter in MissionSquad AND (alive _spotter)} do {
	potential = [];
	suspectedEnemy = [];
	if (isNil "inPlayMarkers") then {inPlayMarkers = []};
	_center = _spotter;
	_radius = 100;
	potential = nearestObjects [_center, ["man"], _radius];

	{
	if ((_x select 2) == EAST) then {
		suspectedEnemy set [count suspectedEnemy, (_x select 0)];
	};
	} forEach potential;
	
	{
	deleteMarkerLocal _x;
	} forEach inPlayMarkers;
	inPlayMarkers = [];
	{
	
	_mrkName = format["mrk%1", str(_x)];
	_mrk = createMarkerLocal[_mrkName, [_x select 0, _x select 1]];
	_mrk setMarkerShapeLocal "ICON";
	_mrk setMarkerTypeLocal "b_inf";
	_mrk setMarkerColorLocal "ColorOPFOR";
	inPlayMarkers = inPlayMarkers + [_mrkName];
	} forEach suspectedEnemy;
	sleep (10 + (random 10));
  };
};

 

 

 

06367540c5c497c0a0aa4447bf7827f20d9cdf31

 

The script is supposed to show enemies on the map via markers every 10+random10 seconds if the spotter is on the player's team.

 

I have not been able to fix it, any ideas?

Share this post


Link to post
Share on other sites

I'm not sure of this should have ever worked at all:

 

if ((_x select 2) == EAST)

should be

if (side _x == EAST)

 

Keep in mind, I'm only looking at this from my phone. Could be something else happening in there as well. 

  • Like 2
  • Thanks 1

Share this post


Link to post
Share on other sites

Ok that did not fixed the issue. 

 

I completely rewrote the script and now it is working like a charm!

 

if (!isServer) exitWith {};

_unit = _this select 0;

if (isPlayer _unit) exitWith {};
if (!local _unit) exitWith {};

while {alive _unit} do {
	waitUntil {sleep 1; _unit in MissionSquad};
	hint format["As %1 (Spotter) joins the squad, Posible contacts positions in a 50 mtr. radius will be updated on map every 10 sec",name _unit];	
		while {sleep 1; _unit in MissionSquad AND (alive _unit)} do {
		_radius = 100;
		_center = _unit;
		_deleteTime = 10;
		_posTolerance = 3;
		_nearestTargets = nearestObjects [_center, ["man"], _radius];
		_validNearestTargets = [];
		{
		if (alive _x && (side _x == EAST)) then {
		_validNearestTargets set [(count _validNearestTargets),_x];
		};
		} forEach _nearestTargets;
		hint format ["%1", _validNearestTargets];
		[_unit,"Marking nearby contacts on map..."] remoteExec ["sideChat" ,0];
		for "_i" from 0 to (count _validNearestTargets) - 1 do
			{
			_enemy = _validNearestTargets select _i;
			if (side _enemy != side _unit) then {
				_marker = createMarker [format ["tempMarker_%1",_i], [_enemy, _posTolerance, random(360)] call BIS_fnc_relPos];
				format ["tempMarker_%1",_i] setMarkerType "o_unknown";
				format ["tempMarker_%1",_i] setMarkerColor "ColorUNKNOWN";
				format ["tempMarker_%1",_i] setMarkerSize [0.5, 0.5];
				}; 
			sleep 1;
			};
		systemChat format ["%1 posible hostiles found.",count _validNearestTargets];
		systemChat format ["Position tolerance: %1 m",_posTolerance];
		sleep _deleteTime;

		for "_i" from 0 to (count _validNearestTargets) - 1 do
			{
				deleteMarker format ["tempMarker_%1",_i];
				sleep 1;
			};
		};
	hint format["As %1 leaves squad, no nearby Enemy positions will be updated on map",name _unit];
	sleep (random 3);
};

 

  • Like 4

Share this post


Link to post
Share on other sites

The scout sending mortar fire to an enemies location feature would be really nice.

  • Like 1

Share this post


Link to post
Share on other sites
5 minutes ago, JohnKalo said:

The scout sending mortar fire

 

I think there is a script for a "forward artillery observer" , i'm going to check it !

  • Thanks 1

Share this post


Link to post
Share on other sites

All scripts I have tried so far did not work. They showed no errors but they also just did not work.

  • Like 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
Sign in to follow this  

×