Jump to content
johnw7392

Whitelisted Zone

Recommended Posts

Hello All,

I am new to the forums here and have a quick question for all you the genius scripters here. In my mission, I would like to have a specific zone on the map to be a "whitelisted" zone so if you enter the zone and are not on the whitelist the you get teleport out of the zone. I am trying to find other topics about this but to no avail. I also attached a pic to help describe what i'm trying to achieve, if a player walks into zone "A"  then a UID Whitelist is checked for their UID, if they are not on the whitelist the they will be teleported back to zone "B". I hope this helps and hope someone can help me solve this issue. 

 

 

cjb8i8

Share this post


Link to post
Share on other sites


private _myWhiteList = ["id1","id2","id3"];

while {true} do

{

{

if ((!getPlayerUID _x in _myWhiteList) && _x inArea "zoneA") then

{

_x setPos getMarkerPos "zoneB";// or getPos "zoneB", depending on what the zones are

};

} count allPlayers;

sleep 3;

};

  • Like 2

Share this post


Link to post
Share on other sites
private _myWhiteList = ["id1","id2","id3"];

while {true} do
{
	{
		if ((!getPlayerUID _x in _myWhiteList) && _x inArea "zoneA") then
		{
			_x setPos getMarkerPos "zoneB";// or getPos "zoneB", depending on what the zones are
		};
	} count allPlayers;
	sleep 3;
};

I see count being used often like this. Is it better than forEach?

Share this post


Link to post
Share on other sites

It's marginally faster, but lacks an index and expects bool or nothing so it's horses for courses.

  • Like 1

Share this post


Link to post
Share on other sites

I must be doing this wrong some how and can't figure it out, nothing I try works. I took the code that Jshock provided and saved it as "towWhitelist.sqf" in my scripts folder. Then I added [] execVM "scripts\towWhitelist.sqf" to my init.sqf. From there I created an area in my mission and named it "towZone" this being the area I only want whitelisted players able to enter. Then I placed down a helipad while testing named "zoneTP" this being the place non-whitelisted players get tp'd to. I then try to test the mission in an MP environment but get an error message as soon as I finish loading. Can anybody help solve this issue? I will provide links to images of the error.

 

 

1. Original Code Provided (edited to work with my markers)

private _myWhiteList = ["id1","id2","id3"];

while {true} do
{
	{
		if ((!getPlayerUID _x in _myWhiteList) && _x inArea "towZone") then
		{
			_x setPos getMarkerPos "zoneTP";// or getPos "zoneB", depending on what the zones are
		};
	} count allPlayers;
	sleep 3;
};

2. Link to image of Error Message

http://prnt.sc/cjp7vj

 

3. Link to 2d image of "Restricted" area marker

http://prnt.sc/cjp82f

 

4. Link to 3d image of "Restricted" area marker

http://prnt.sc/cjp7ms

Share this post


Link to post
Share on other sites

I think your placement of the "!" was the issue. This should do:

 

if ( (!(getPlayerUID _x) in _myWhiteList) && (_x inArea "towZone") ) then

 

 

If you don't mind running it locally instead of on the server, you could also do it with a very simple trigger:

 

 

condition:

player in thisList

 

onAct:

if( (getPlayerUID player) in yourPublicWhiteListVariable ) then { ....whatever } else { hint "welcome to this very exclusive zone"; }

Share this post


Link to post
Share on other sites

Yup my apologies, kinda threw that together quickly :p (the below should also work):

if (!(getPlayerUID _x in _myWhiteList) && (_x inArea "zoneA")) then {blah};
And just an FYI, the _myWhiteList variable needs to contain all the approved player ID strings for your area, not what I provided, those are just for example purposes :).

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

×