Jump to content
Sign in to follow this  
Spriterfight

HELP With ai detecting script

Recommended Posts

	
_locations = nearestLocations [ position player, ["Airport", "NameLocal", "NameVillage", "NameCity", "NameCityCapital","NameMarine"],600];




_markers =  _locations;
_markerdist = 500;



	while {true} do {
{



		if ({player distance getPos _x < _markerdist} forEach _markers) then
		{
			hint "work";
{
[_x] call fnc_detectai;
} forEach _markers;

}
else {sleep 5;};
};

I have a problem.So i want that if the player is near multiple locations then the function will be activated.But when i go near a town it wont actiave the function.What is the problem?So i want that the funcion  to be activated with each location where the player is close.

For example my player is close to 2 location then the function have to be activated on each.

Share this post


Link to post
Share on other sites

You're getting an array of locations from nearestLocations.

getPos _x won't work on a location, you'd need locationPosition for that. Edit: See my post below.

 

Also the entire thing doesn't make much sense.

Why search for locations within 600m just to see if any is closer than 500m?

Simply search for 500m and count the returning array instead, if that count is above 1, there's a location within 500m.

 

Also don't name an array containing locations _markers, that can be confusing later down the line, since markers and locations are different data types (string vs location).

 

Cheers

 

 

  • Like 3

Share this post


Link to post
Share on other sites
3 minutes ago, Grumpy Old Man said:

You're getting an array of locations from nearestLocations.

getPos _x won't work on a location, you'd need locationPosition for that.

 

Also the entire thing doesn't make much sense.

Why search for locations within 600m just to see if any is closer than 500m?

Simply search for 500m and count the returning array instead, if that count is above 1, there's a location within 500m.

 

Also don't name an array containing locations _markers, that can be confusing later down the line, since markers and locations are different data types (string vs location).

 

Cheers

 

 

Thank you.Just testing things around and i forget to change the names of the variables.If i use _loc = _locations apply {getpos _x}; it works

  • Like 2

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  

×