Jump to content
  • 0

Zones/Markers that Shrink - Check if player is outside of zone.


choppra

Question

Hey guys,

 

 

I have a marker that gets created on a map.  It's activated about 30 minutes into the server being up.  How can I check to see if a player is inside our outside the Marker area?

 

The zone shrinks every 15 minutes.  What's the best way going about seeing if a player is inside or outside the zone?

 

while {true} do { 

_mar_name = createMarker ["ZoneMarker", _FinalZoneCenter];
"ZoneMarker" setMarkerShape "ELLIPSE";
"ZoneMarker" setMarkerBrush  "GRID";
"ZoneMarker" setMarkerColor  "ColorBlue";
"ZoneMarker" setMarkerSize [_startingzone,_startingzone];
sleep 900;
_startingzone = (_startingzone) - (500);
[nil,nil,rTitleText,"Test - Shrinking Zone by 500km","PLAIN",10] call RE;


};

 

Link to comment
Share on other sites

10 answers to this question

Recommended Posts

  • 0

yeah i've been looking at it but i cant seem to find at which point it checks the player location relevant to a marker.

It checks the global variable 'canbuild' which is set to false by player_trader_City.sqf when a player is in range of the trader triggers set within the mission.sqm.

 

So, for your task I would place the marker, create a trigger/sensor calling a similar script to  player_trader_City at the same spot with initial size x.  As timer decrements, decrease size of sensor.  Not sure whether you can simply resize the sensor, or if you would have to delete it and create another, smaller, one.  I'm pretty sure with markers you can simply 'create' a new marker with the s same name and it just moves the marker, not sure if triggers are the same.

Link to comment
Share on other sites

  • 0

In theory, shouldn't this work? I tested it out but it keeps saying I am not in the zone

private["_FinalZoneCenter","_startingzone","_mar_name","_inzone","_pos","_mark","_loc"];
	
sleep 5;
[nil,nil,rTitleText,"Safe Zone is Marked!","PLAIN",10] call RE;

_FinalZoneCenter = [9114.96,5402.52,0];
_startingzone = 3000;

sleep 10;
while{true}do
    {
                 _mar_name =	createMarker ["ZoneMarker", _FinalZoneCenter];
		"ZoneMarker"	setMarkerShape	"ELLIPSE";
		"ZoneMarker"	setMarkerBrush  "GRID";
		"ZoneMarker"	setMarkerColor  "ColorBlue";
		"ZoneMarker" 	setMarkerSize	[_startingzone,_startingzone];		

		_pos = getPOS Player;
		_mark = "ZoneMarker"
		_loc = createLocation (["Name", markerPos _mark] + (markerSize _mark));

		if (_pos in _loc) then { 

		[nil,nil,rTitleText,"You are DEFINATELY IN the ZONE","PLAIN",10] call RE;
		Sleep 5;
		} else {

		[nil,nil,rTitleText,"You are NOT IN the ZONE","PLAIN",10] call RE; 
                };
		deleteLocation _loc;
}; 

.

Link to comment
Share on other sites

  • 0

Nice try choppra, but markers are created server side. Therefore you can't do this

_pos = getPOS Player;

also, no matter how you do it, this will never work:

"ZoneMarker" 	setMarkerSize	[_startingzone,_startingzone];	
Link to comment
Share on other sites

  • 0

The marker is created just fine.  There is no issue there.  I can even run a seperate loop to shrink the zone as described in my first post.  All that works OK.

 

It's just detecting if the player is in the zone I can't get.  Are you saying its not possible?

Link to comment
Share on other sites

  • 0

The marker is created just fine.  There is no issue there.  I can even run a seperate loop to shrink the zone as described in my first post.  All that works OK.

 

It's just detecting if the player is in the zone I can't get.  Are you saying its not possible?

 

Umm no, my issue. I meant, that by using a fixed _startingzone - the marker most likely change in position each time it shrinks.

//This is a Loop, that was used for another purpose, but could suit your situation just fine. Thanks to MGM. 

//Create your marker here, with the valid Marker position

while {true} do {
	//_matchingObjectsArray = ((units _unitGroup) select 0) nearEntities ["CAManBase",1250]; - Original

        //How it could look: _matchingObjectsArray = ("Name of Marker") nearEntities ["CAManBase",1250];

	_numberOfMatchingObjectsNumber = (count _matchingObjectsArray);
	if (_numberOfMatchingObjectsNumber >= 1) then {
		{
			if (isPlayer _x) then {
				//Player is in the Area, do something... 
			};
		} foreach _matchingObjectsArray;
	};
	sleep 15;
};

Now in this loop it will check every 15 seconds, if a player is within the given area. I believe it could work with the Marker Name, simply and then check for nearEntities. You you might want to adjust the sleep time.

 

 

//EDIT: Also it is unnecessary to continuously delete and create a marker. If you have only one marker, you can use the marker Name to update the marker size. "Marker_Name" setMarkerSize [150,150];"

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Advertisement
  • Discord

×
×
  • Create New...